diff options
author | Eduardo Julian | 2020-12-25 09:22:38 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-12-25 09:22:38 -0400 |
commit | 4ca397765805eda5ddee393901ed3a02001a960a (patch) | |
tree | 2ab184a1a4e244f3a69e86c8a7bb3ad49c22b4a3 /stdlib/source/test/lux/control/parser | |
parent | d29e091e98dabb8dfcf816899ada480ecbf7e357 (diff) |
Replaced kebab-case with snake_case for naming convention.
Diffstat (limited to 'stdlib/source/test/lux/control/parser')
-rw-r--r-- | stdlib/source/test/lux/control/parser/analysis.lux | 12 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/parser/binary.lux | 142 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/parser/code.lux | 54 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/parser/json.lux | 66 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/parser/synthesis.lux | 113 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/parser/text.lux | 316 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/parser/type.lux | 152 | ||||
-rw-r--r-- | stdlib/source/test/lux/control/parser/xml.lux | 44 |
8 files changed, 450 insertions, 449 deletions
diff --git a/stdlib/source/test/lux/control/parser/analysis.lux b/stdlib/source/test/lux/control/parser/analysis.lux index e089fb4d2..daf3632d6 100644 --- a/stdlib/source/test/lux/control/parser/analysis.lux +++ b/stdlib/source/test/lux/control/parser/analysis.lux @@ -81,7 +81,7 @@ [/.bit /.bit! random.bit analysis.bit bit\=] [/.nat /.nat! random.nat analysis.nat n.=] [/.int /.int! random.int analysis.int i.=] - [/.frac /.frac! random.safe-frac analysis.frac f.=] + [/.frac /.frac! random.safe_frac analysis.frac f.=] [/.rev /.rev! random.rev analysis.rev r.=] [/.text /.text! (random.unicode 10) analysis.text text\=] [/.local /.local! random.nat analysis.variable/local n.=] @@ -118,29 +118,29 @@ (!expect (#try.Failure _)))))) (do {! random.monad} [expected random.bit] - (_.cover [/.cannot-parse] + (_.cover [/.cannot_parse] (and (|> (list (analysis.bit expected)) (/.run /.nat) (case> (#try.Success _) false (#try.Failure error) - (exception.match? /.cannot-parse error))) + (exception.match? /.cannot_parse error))) (|> (list) (/.run /.bit) (case> (#try.Success _) false (#try.Failure error) - (exception.match? /.cannot-parse error)))))) + (exception.match? /.cannot_parse error)))))) (do {! random.monad} [expected random.bit] - (_.cover [/.unconsumed-input] + (_.cover [/.unconsumed_input] (|> (list (analysis.bit expected) (analysis.bit expected)) (/.run /.bit) (case> (#try.Success _) false (#try.Failure error) - (exception.match? /.unconsumed-input error))))) + (exception.match? /.unconsumed_input error))))) ))))) diff --git a/stdlib/source/test/lux/control/parser/binary.lux b/stdlib/source/test/lux/control/parser/binary.lux index 88c4aafaa..2a29ba367 100644 --- a/stdlib/source/test/lux/control/parser/binary.lux +++ b/stdlib/source/test/lux/control/parser/binary.lux @@ -47,9 +47,9 @@ _ false)) -(def: segment-size 10) +(def: segment_size 10) -(def: (utf8-conversion-does-not-alter? value) +(def: (utf8_conversion_does_not_alter? value) (Predicate Text) (|> value (\ encoding.utf8 encode) @@ -60,58 +60,58 @@ (#try.Failure error) false))) -(def: random-text +(def: random_text (Random Text) - (random.filter ..utf8-conversion-does-not-alter? - (random.unicode ..segment-size))) + (random.filter ..utf8_conversion_does_not_alter? + (random.unicode ..segment_size))) -(def: random-name +(def: random_name (Random Name) - (random.and ..random-text ..random-text)) + (random.and ..random_text ..random_text)) -(structure: location-equivalence +(structure: location_equivalence (Equivalence Location) - (def: (= [expected-module expected-line expected-column] - [sample-module sample-line sample-column]) - (and (text\= expected-module sample-module) - (n.= expected-line sample-line) - (n.= expected-column sample-column)))) + (def: (= [expected_module expected_line expected_column] + [sample_module sample_line sample_column]) + (and (text\= expected_module sample_module) + (n.= expected_line sample_line) + (n.= expected_column sample_column)))) -(def: random-location +(def: random_location (Random Location) ($_ random.and - ..random-text + ..random_text random.nat random.nat)) -(def: random-code +(def: random_code (Random Code) (random.rec (function (_ recur) - (let [random-sequence (do {! random.monad} + (let [random_sequence (do {! random.monad} [size (\ ! map (n.% 2) random.nat)] (random.list size recur))] ($_ random.and - ..random-location + ..random_location (: (Random (Code' (Ann Location))) ($_ random.or random.bit random.nat random.int random.rev - random.safe-frac - ..random-text - ..random-name - ..random-name - random-sequence - random-sequence + random.safe_frac + ..random_text + ..random_name + ..random_name + random_sequence + random_sequence (do {! random.monad} [size (\ ! map (n.% 2) random.nat)] (random.list size (random.and recur recur))) ))))))) -(def: random-type +(def: random_type (Random Type) (let [(^open ".") random.monad] ($_ random.either @@ -146,7 +146,7 @@ (`` ($_ _.and (~~ (template [<parser> <format>] [(do {! random.monad} - [expected (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] + [expected (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] (_.cover [<parser> <format>] (|> (format.run <format> expected) (/.run <parser>) @@ -164,7 +164,7 @@ (`` ($_ _.and (~~ (template [<parser> <format>] [(do {! random.monad} - [expected (random.ascii ..segment-size)] + [expected (random.ascii ..segment_size)] (_.cover [<parser> <format>] (|> (format.run <format> expected) (/.run <parser>) @@ -183,7 +183,7 @@ (`` ($_ _.and (~~ (template [<parser> <format>] [(do {! random.monad} - [expected (random.row ..segment-size random.nat)] + [expected (random.row ..segment_size random.nat)] (_.cover [<parser> <format>] (|> expected (format.run (<format> format.nat)) @@ -222,18 +222,18 @@ (/.run /.frac) (!expect (^multi (#try.Success actual) (or (\ frac.equivalence = expected actual) - (and (frac.not-a-number? expected) - (frac.not-a-number? actual)))))))) + (and (frac.not_a_number? expected) + (frac.not_a_number? actual)))))))) (do {! random.monad} [expected (\ ! map (|>> (i64.and (i64.mask /.size/8)) (n.max 2)) random.nat)] - (_.cover [/.not-a-bit] + (_.cover [/.not_a_bit] (|> expected (format.run format.bits/8) (/.run /.bit) (!expect (^multi (#try.Failure error) - (exception.match? /.not-a-bit error)))))) + (exception.match? /.not_a_bit error)))))) ))) (def: complex @@ -249,14 +249,14 @@ (!expect (^multi (#try.Success actual) (\ <equivalence> = expected actual))))))] - [/.location format.location random-location location-equivalence] - [/.code format.code random-code code.equivalence] - [/.type format.type random-type type.equivalence] + [/.location format.location random_location location_equivalence] + [/.code format.code random_code code.equivalence] + [/.type format.type random_type type.equivalence] )) - (~~ (template [<parser-coverage> <parser> <format-coverage> <format> <random> <equivalence>] + (~~ (template [<parser_coverage> <parser> <format_coverage> <format> <random> <equivalence>] [(do {! random.monad} [expected <random>] - (_.cover [<parser-coverage> <format-coverage>] + (_.cover [<parser_coverage> <format_coverage>] (|> expected (format.run <format>) (/.run <parser>) @@ -264,17 +264,17 @@ (\ <equivalence> = expected actual))))))] [/.maybe (/.maybe /.nat) format.maybe (format.maybe format.nat) (random.maybe random.nat) (maybe.equivalence n.equivalence)] - [/.list (/.list /.nat) format.list (format.list format.nat) (random.list ..segment-size random.nat) (list.equivalence n.equivalence)] - [/.set (/.set n.hash /.nat) format.set (format.set format.nat) (random.set n.hash ..segment-size random.nat) set.equivalence] - [/.name /.name format.name format.name ..random-name name.equivalence])) + [/.list (/.list /.nat) format.list (format.list format.nat) (random.list ..segment_size random.nat) (list.equivalence n.equivalence)] + [/.set (/.set n.hash /.nat) format.set (format.set format.nat) (random.set n.hash ..segment_size random.nat) set.equivalence] + [/.name /.name format.name format.name ..random_name name.equivalence])) (do {! random.monad} - [expected (\ ! map (list.repeat ..segment-size) random.nat)] - (_.cover [/.set-elements-are-not-unique] + [expected (\ ! map (list.repeat ..segment_size) random.nat)] + (_.cover [/.set_elements_are_not_unique] (|> expected (format.run (format.list format.nat)) (/.run (/.set n.hash /.nat)) (!expect (^multi (#try.Failure error) - (exception.match? /.set-elements-are-not-unique error)))))) + (exception.match? /.set_elements_are_not_unique error)))))) (do {! random.monad} [expected (random.or random.bit random.nat)] (_.cover [/.or format.or] @@ -291,15 +291,15 @@ (n.max 2)) random.nat) value random.bit] - (_.cover [/.invalid-tag] + (_.cover [/.invalid_tag] (|> [tag value] (format.run (format.and format.bits/8 format.bit)) (/.run (: (/.Parser (Either Bit Nat)) (/.or /.bit /.nat))) (!expect (^multi (#try.Failure error) - (exception.match? /.invalid-tag error)))))) + (exception.match? /.invalid_tag error)))))) (do {! random.monad} - [expected (random.list ..segment-size random.nat)] + [expected (random.list ..segment_size random.nat)] (_.cover [/.rec format.rec format.and format.any] (|> expected (format.run (format.rec (|>> (format.and format.nat) @@ -322,64 +322,64 @@ (_.for [/.Parser]) (`` ($_ _.and (_.cover [/.run /.any - format.no-op format.instance] - (|> (format.instance format.no-op) + format.no_op format.instance] + (|> (format.instance format.no_op) (/.run /.any) (!expect (#try.Success _)))) (do {! random.monad} - [data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] - (_.cover [/.binary-was-not-fully-read] + [data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] + (_.cover [/.binary_was_not_fully_read] (|> data (/.run /.any) (!expect (^multi (#try.Failure error) - (exception.match? /.binary-was-not-fully-read error)))))) + (exception.match? /.binary_was_not_fully_read error)))))) (do {! random.monad} - [expected (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] + [expected (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] (_.cover [/.segment format.segment format.run] (|> expected - (format.run (format.segment ..segment-size)) - (/.run (/.segment ..segment-size)) + (format.run (format.segment ..segment_size)) + (/.run (/.segment ..segment_size)) (!expect (^multi (#try.Success actual) (\ binary.equivalence = expected actual)))))) (do {! random.monad} - [data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] + [data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] (_.cover [/.end?] (|> data (/.run (do <>.monad [pre /.end? - _ (/.segment ..segment-size) + _ (/.segment ..segment_size) post /.end?] (wrap (and (not pre) post)))) (!expect (#try.Success #1))))) (do {! random.monad} - [to-read (\ ! map (n.% (inc ..segment-size)) random.nat) - data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] + [to_read (\ ! map (n.% (inc ..segment_size)) random.nat) + data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] (_.cover [/.Offset /.offset] (|> data (/.run (do <>.monad [start /.offset - _ (/.segment to-read) + _ (/.segment to_read) offset /.offset - _ (/.segment (n.- to-read ..segment-size)) - nothing-left /.offset] + _ (/.segment (n.- to_read ..segment_size)) + nothing_left /.offset] (wrap (and (n.= 0 start) - (n.= to-read offset) - (n.= ..segment-size nothing-left))))) + (n.= to_read offset) + (n.= ..segment_size nothing_left))))) (!expect (#try.Success #1))))) (do {! random.monad} - [to-read (\ ! map (n.% (inc ..segment-size)) random.nat) - data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment-size))] + [to_read (\ ! map (n.% (inc ..segment_size)) random.nat) + data (\ ! map (\ encoding.utf8 encode) (random.ascii ..segment_size))] (_.cover [/.remaining] (|> data (/.run (do <>.monad - [_ (/.segment to-read) + [_ (/.segment to_read) remaining /.remaining - _ (/.segment (n.- to-read ..segment-size)) - nothing-left /.remaining] - (wrap (and (n.= ..segment-size - (n.+ to-read remaining)) - (n.= 0 nothing-left))))) + _ (/.segment (n.- to_read ..segment_size)) + nothing_left /.remaining] + (wrap (and (n.= ..segment_size + (n.+ to_read remaining)) + (n.= 0 nothing_left))))) (!expect (#try.Success #1))))) ..size ..binary diff --git a/stdlib/source/test/lux/control/parser/code.lux b/stdlib/source/test/lux/control/parser/code.lux index 0c2c42c8e..71aa8f39d 100644 --- a/stdlib/source/test/lux/control/parser/code.lux +++ b/stdlib/source/test/lux/control/parser/code.lux @@ -33,7 +33,7 @@ _ false)) -(def: random-name +(def: random_name (Random Name) (random.and (random.unicode 1) (random.unicode 1))) @@ -71,48 +71,48 @@ [/.nat /.nat! random.nat code.nat nat.equivalence] [/.int /.int! random.int code.int int.equivalence] [/.rev /.rev! random.rev code.rev rev.equivalence] - [/.frac /.frac! random.safe-frac code.frac frac.equivalence] + [/.frac /.frac! random.safe_frac code.frac frac.equivalence] [/.text /.text! (random.unicode 1) code.text text.equivalence] - [/.identifier /.identifier! ..random-name code.identifier name.equivalence] - [/.tag /.tag! ..random-name code.tag name.equivalence] - [/.local-identifier /.local-identifier! (random.unicode 1) code.local-identifier text.equivalence] - [/.local-tag /.local-tag! (random.unicode 1) code.local-tag text.equivalence] + [/.identifier /.identifier! ..random_name code.identifier name.equivalence] + [/.tag /.tag! ..random_name code.tag name.equivalence] + [/.local_identifier /.local_identifier! (random.unicode 1) code.local_identifier text.equivalence] + [/.local_tag /.local_tag! (random.unicode 1) code.local_tag text.equivalence] )) (~~ (template [<query> <code>] [(do {! random.monad} - [expected-left random.nat - expected-right random.int] + [expected_left random.nat + expected_right random.int] (_.cover [<query>] (|> (/.run (<query> (<>.and /.nat /.int)) - (list (<code> (list (code.nat expected-left) - (code.int expected-right))))) - (!expect (^multi (#try.Success [actual-left actual-right]) - (and (\ nat.equivalence = expected-left actual-left) - (\ int.equivalence = expected-right actual-right)))))))] + (list (<code> (list (code.nat expected_left) + (code.int expected_right))))) + (!expect (^multi (#try.Success [actual_left actual_right]) + (and (\ nat.equivalence = expected_left actual_left) + (\ int.equivalence = expected_right actual_right)))))))] [/.form code.form] [/.tuple code.tuple] )) (do {! random.monad} - [expected-left random.nat - expected-right random.int] + [expected_left random.nat + expected_right random.int] (_.cover [/.record] (|> (/.run (/.record (<>.and /.nat /.int)) - (list (code.record (list [(code.nat expected-left) - (code.int expected-right)])))) - (!expect (^multi (#try.Success [actual-left actual-right]) - (and (\ nat.equivalence = expected-left actual-left) - (\ int.equivalence = expected-right actual-right))))))) + (list (code.record (list [(code.nat expected_left) + (code.int expected_right)])))) + (!expect (^multi (#try.Success [actual_left actual_right]) + (and (\ nat.equivalence = expected_left actual_left) + (\ int.equivalence = expected_right actual_right))))))) (do {! random.monad} - [expected-local random.nat - expected-global random.int] + [expected_local random.nat + expected_global random.int] (_.cover [/.local] - (|> (/.run (<>.and (/.local (list (code.nat expected-local)) /.nat) + (|> (/.run (<>.and (/.local (list (code.nat expected_local)) /.nat) /.int) - (list (code.int expected-global))) - (!expect (^multi (#try.Success [actual-local actual-global]) - (and (\ nat.equivalence = expected-local actual-local) - (\ int.equivalence = expected-global actual-global))))))) + (list (code.int expected_global))) + (!expect (^multi (#try.Success [actual_local actual_global]) + (and (\ nat.equivalence = expected_local actual_local) + (\ int.equivalence = expected_global actual_global))))))) (do {! random.monad} [dummy (\ ! map code.bit random.bit)] (_.cover [/.end?] diff --git a/stdlib/source/test/lux/control/parser/json.lux b/stdlib/source/test/lux/control/parser/json.lux index cb6928062..b9d111eff 100644 --- a/stdlib/source/test/lux/control/parser/json.lux +++ b/stdlib/source/test/lux/control/parser/json.lux @@ -35,9 +35,9 @@ _ false)) -(def: safe-frac +(def: safe_frac (Random Frac) - (random.filter (|>> frac.not-a-number? not) random.frac)) + (random.filter (|>> frac.not_a_number? not) random.frac)) (def: #export test Test @@ -74,23 +74,23 @@ (!expect (#try.Failure _)))))))] [/.boolean /.boolean? /.boolean! random.bit #json.Boolean bit.equivalence] - [/.number /.number? /.number! ..safe-frac #json.Number frac.equivalence] + [/.number /.number? /.number! ..safe_frac #json.Number frac.equivalence] [/.string /.string? /.string! (random.unicode 1) #json.String text.equivalence] )) (do {! random.monad} [expected (random.unicode 1) dummy random.bit] - (_.cover [/.unexpected-value] + (_.cover [/.unexpected_value] (|> (/.run /.string (#json.Boolean dummy)) (!expect (^multi (#try.Failure error) - (exception.match? /.unexpected-value error)))))) + (exception.match? /.unexpected_value error)))))) (do {! random.monad} [expected (random.unicode 1) dummy (|> (random.unicode 1) (random.filter (|>> (\ text.equivalence = expected) not)))] - (_.cover [/.value-mismatch] + (_.cover [/.value_mismatch] (|> (/.run (/.string! expected) (#json.String dummy)) (!expect (^multi (#try.Failure error) - (exception.match? /.value-mismatch error)))))) + (exception.match? /.value_mismatch error)))))) (do {! random.monad} [expected (random.unicode 1)] (_.cover [/.nullable] @@ -104,59 +104,59 @@ [size (\ ! map (n.% 10) random.nat) expected (|> (random.unicode 1) (random.list size) - (\ ! map row.from-list))] + (\ ! map row.from_list))] (_.cover [/.array] (|> (/.run (/.array (<>.some /.string)) (#json.Array (row\map (|>> #json.String) expected))) (!expect (^multi (#try.Success actual) - (\ (row.equivalence text.equivalence) = expected (row.from-list actual))))))) + (\ (row.equivalence text.equivalence) = expected (row.from_list actual))))))) (do {! random.monad} [expected (\ ! map (|>> #json.String) (random.unicode 1))] - (_.cover [/.unconsumed-input] + (_.cover [/.unconsumed_input] (|> (/.run (/.array /.any) (#json.Array (row expected expected))) (!expect (^multi (#try.Failure error) - (exception.match? /.unconsumed-input error)))))) - (_.cover [/.empty-input] + (exception.match? /.unconsumed_input error)))))) + (_.cover [/.empty_input] (|> (/.run (/.array /.any) (#json.Array (row))) (!expect (^multi (#try.Failure error) - (exception.match? /.empty-input error))))) + (exception.match? /.empty_input error))))) (do {! random.monad} - [expected-boolean random.bit - expected-number ..safe-frac - expected-string (random.unicode 1) - [boolean-field number-field string-field] (|> (random.set text.hash 3 (random.unicode 3)) - (\ ! map (|>> set.to-list - (case> (^ (list boolean-field number-field string-field)) - [boolean-field number-field string-field] + [expected_boolean random.bit + expected_number ..safe_frac + expected_string (random.unicode 1) + [boolean_field number_field string_field] (|> (random.set text.hash 3 (random.unicode 3)) + (\ ! map (|>> set.to_list + (case> (^ (list boolean_field number_field string_field)) + [boolean_field number_field string_field] _ (undefined)))))] (_.cover [/.object /.field] (|> (/.run (/.object ($_ <>.and - (/.field boolean-field /.boolean) - (/.field number-field /.number) - (/.field string-field /.string))) + (/.field boolean_field /.boolean) + (/.field number_field /.number) + (/.field string_field /.string))) (#json.Object - (dictionary.from-list text.hash - (list [boolean-field (#json.Boolean expected-boolean)] - [number-field (#json.Number expected-number)] - [string-field (#json.String expected-string)])))) - (!expect (^multi (#try.Success [actual-boolean actual-number actual-string]) - (and (\ bit.equivalence = expected-boolean actual-boolean) - (\ frac.equivalence = expected-number actual-number) - (\ text.equivalence = expected-string actual-string))))))) + (dictionary.from_list text.hash + (list [boolean_field (#json.Boolean expected_boolean)] + [number_field (#json.Number expected_number)] + [string_field (#json.String expected_string)])))) + (!expect (^multi (#try.Success [actual_boolean actual_number actual_string]) + (and (\ bit.equivalence = expected_boolean actual_boolean) + (\ frac.equivalence = expected_number actual_number) + (\ text.equivalence = expected_string actual_string))))))) (do {! random.monad} [size (\ ! map (n.% 10) random.nat) keys (random.list size (random.unicode 1)) values (random.list size (random.unicode 1)) - #let [expected (dictionary.from-list text.hash (list.zip/2 keys values))]] + #let [expected (dictionary.from_list text.hash (list.zip/2 keys values))]] (_.cover [/.dictionary] (|> (/.run (/.dictionary /.string) (#json.Object (|> values (list\map (|>> #json.String)) (list.zip/2 keys) - (dictionary.from-list text.hash)))) + (dictionary.from_list text.hash)))) (!expect (^multi (#try.Success actual) (\ (dictionary.equivalence text.equivalence) = expected actual)))))) )))) diff --git a/stdlib/source/test/lux/control/parser/synthesis.lux b/stdlib/source/test/lux/control/parser/synthesis.lux index daf44e7ae..b47f8338c 100644 --- a/stdlib/source/test/lux/control/parser/synthesis.lux +++ b/stdlib/source/test/lux/control/parser/synthesis.lux @@ -39,21 +39,21 @@ _ false)) -(def: random-constant +(def: random_constant (Random Name) (random.and (random.unicode 1) (random.unicode 1))) -(def: random-variable +(def: random_variable (Random Variable) (random.or random.nat random.nat)) -(def: random-environment +(def: random_environment (Random (Environment Synthesis)) (do {! random.monad} [size (\ ! map (n.% 5) random.nat)] - (|> ..random-variable + (|> ..random_variable (\ ! map (|>> synthesis.variable)) (random.list size)))) @@ -74,15 +74,16 @@ (!expect (#try.Success _))) (|> (/.run (<check> expected) (list (<synthesis> dummy))) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-parse error))))))))] + (exception.match? /.cannot_parse error)))))) + ))] [/.bit /.bit! random.bit synthesis.bit bit.equivalence] [/.i64 /.i64! (\ ! map .i64 random.nat) synthesis.i64 i64.equivalence] - [/.f64 /.f64! random.safe-frac synthesis.f64 frac.equivalence] + [/.f64 /.f64! random.safe_frac synthesis.f64 frac.equivalence] [/.text /.text! (random.unicode 1) synthesis.text text.equivalence] [/.local /.local! random.nat synthesis.variable/local n.equivalence] [/.foreign /.foreign! random.nat synthesis.variable/foreign n.equivalence] - [/.constant /.constant! ..random-constant synthesis.constant name.equivalence] + [/.constant /.constant! ..random_constant synthesis.constant name.equivalence] )) ))) @@ -90,70 +91,70 @@ Test ($_ _.and (do {! random.monad} - [expected-bit random.bit - expected-i64 (\ ! map .i64 random.nat) - expected-f64 random.safe-frac - expected-text (random.unicode 1)] + [expected_bit random.bit + expected_i64 (\ ! map .i64 random.nat) + expected_f64 random.safe_frac + expected_text (random.unicode 1)] (_.cover [/.tuple] (and (|> (/.run (/.tuple ($_ <>.and /.bit /.i64 /.f64 /.text)) - (list (synthesis.tuple (list (synthesis.bit expected-bit) - (synthesis.i64 expected-i64) - (synthesis.f64 expected-f64) - (synthesis.text expected-text))))) - (!expect (^multi (#try.Success [actual-bit actual-i64 actual-f64 actual-text]) - (and (\ bit.equivalence = expected-bit actual-bit) - (\ i64.equivalence = expected-i64 actual-i64) - (\ frac.equivalence = expected-f64 actual-f64) - (\ text.equivalence = expected-text actual-text))))) + (list (synthesis.tuple (list (synthesis.bit expected_bit) + (synthesis.i64 expected_i64) + (synthesis.f64 expected_f64) + (synthesis.text expected_text))))) + (!expect (^multi (#try.Success [actual_bit actual_i64 actual_f64 actual_text]) + (and (\ bit.equivalence = expected_bit actual_bit) + (\ i64.equivalence = expected_i64 actual_i64) + (\ frac.equivalence = expected_f64 actual_f64) + (\ text.equivalence = expected_text actual_text))))) (|> (/.run (/.tuple ($_ <>.and /.bit /.i64 /.f64 /.text)) - (list (synthesis.text expected-text))) + (list (synthesis.text expected_text))) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-parse error))))))) + (exception.match? /.cannot_parse error))))))) (do {! random.monad} [arity random.nat - expected-environment ..random-environment - expected-body (random.unicode 1)] + expected_environment ..random_environment + expected_body (random.unicode 1)] (_.cover [/.function] (and (|> (/.run (/.function arity /.text) - (list (synthesis.function/abstraction [expected-environment arity (synthesis.text expected-body)]))) - (!expect (^multi (#try.Success [actual-environment actual-body]) + (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)]))) + (!expect (^multi (#try.Success [actual_environment actual_body]) (and (\ (list.equivalence synthesis.equivalence) = - expected-environment - actual-environment) - (\ text.equivalence = expected-body actual-body))))) + expected_environment + actual_environment) + (\ text.equivalence = expected_body actual_body))))) (|> (/.run (/.function arity /.text) - (list (synthesis.text expected-body))) + (list (synthesis.text expected_body))) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-parse error))))))) + (exception.match? /.cannot_parse error))))))) (do {! random.monad} [arity random.nat - expected-environment ..random-environment - expected-body (random.unicode 1)] - (_.cover [/.wrong-arity] + expected_environment ..random_environment + expected_body (random.unicode 1)] + (_.cover [/.wrong_arity] (|> (/.run (/.function (inc arity) /.text) - (list (synthesis.function/abstraction [expected-environment arity (synthesis.text expected-body)]))) + (list (synthesis.function/abstraction [expected_environment arity (synthesis.text expected_body)]))) (!expect (^multi (#try.Failure error) - (exception.match? /.wrong-arity error)))))) + (exception.match? /.wrong_arity error)))))) (do {! random.monad} [arity (\ ! map (|>> (n.% 10) inc) random.nat) - expected-offset random.nat - expected-inits (random.list arity random.bit) - expected-body (random.unicode 1)] + expected_offset random.nat + expected_inits (random.list arity random.bit) + expected_body (random.unicode 1)] (_.cover [/.loop] (and (|> (/.run (/.loop (<>.many /.bit) /.text) - (list (synthesis.loop/scope [expected-offset - (list\map (|>> synthesis.bit) expected-inits) - (synthesis.text expected-body)]))) - (!expect (^multi (#try.Success [actual-offset actual-inits actual-body]) - (and (\ n.equivalence = expected-offset actual-offset) + (list (synthesis.loop/scope [expected_offset + (list\map (|>> synthesis.bit) expected_inits) + (synthesis.text expected_body)]))) + (!expect (^multi (#try.Success [actual_offset actual_inits actual_body]) + (and (\ n.equivalence = expected_offset actual_offset) (\ (list.equivalence bit.equivalence) = - expected-inits - actual-inits) - (\ text.equivalence = expected-body actual-body))))) + expected_inits + actual_inits) + (\ text.equivalence = expected_body actual_body))))) (|> (/.run (/.loop (<>.many /.bit) /.text) - (list (synthesis.text expected-body))) + (list (synthesis.text expected_body))) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-parse error))))))) + (exception.match? /.cannot_parse error))))))) )) (def: #export test @@ -167,24 +168,24 @@ (|> (/.run /.any (list expected)) (!expect (^multi (#try.Success actual) (\ synthesis.equivalence = expected actual)))))) - (_.cover [/.empty-input] + (_.cover [/.empty_input] (|> (/.run /.any (list)) (!expect (^multi (#try.Failure error) - (exception.match? /.empty-input error))))) + (exception.match? /.empty_input error))))) (do {! random.monad} [expected (\ ! map (|>> synthesis.i64) random.nat)] - (_.cover [/.unconsumed-input] + (_.cover [/.unconsumed_input] (|> (/.run /.any (list expected expected)) (!expect (^multi (#try.Failure error) - (exception.match? /.unconsumed-input error)))))) + (exception.match? /.unconsumed_input error)))))) (do {! random.monad} [dummy (\ ! map (|>> synthesis.i64) random.nat)] - (_.cover [/.end! /.expected-empty-input] + (_.cover [/.end! /.expected_empty_input] (and (|> (/.run /.end! (list)) (!expect (#try.Success _))) (|> (/.run /.end! (list dummy)) (!expect (^multi (#try.Failure error) - (exception.match? /.expected-empty-input error))))))) + (exception.match? /.expected_empty_input error))))))) (do {! random.monad} [dummy (\ ! map (|>> synthesis.i64) random.nat)] (_.cover [/.end?] @@ -192,7 +193,7 @@ (!expect (#try.Success #1))) (|> (/.run (<>.before /.any /.end?) (list dummy)) (!expect (#try.Success #0)))))) - (_.for [/.cannot-parse] + (_.for [/.cannot_parse] ($_ _.and ..simple ..complex diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux index 8436e30ca..8465393de 100644 --- a/stdlib/source/test/lux/control/parser/text.lux +++ b/stdlib/source/test/lux/control/parser/text.lux @@ -38,7 +38,7 @@ _ false)) -(def: (should-fail' sample parser exception) +(def: (should_fail' sample parser exception) (All [a e] (-> Text (/.Parser a) (Exception e) Bit)) (case (/.run parser sample) (#try.Failure error) @@ -47,7 +47,7 @@ _ false)) -(def: (should-fail sample parser) +(def: (should_fail sample parser) (All [a] (-> Text (/.Parser a) Bit)) (case (/.run parser sample) (#try.Failure _) @@ -56,157 +56,157 @@ _ false)) -(def: (should-pass expected parser) +(def: (should_pass expected parser) (-> Text (/.Parser Text) Bit) (|> expected (/.run parser) (\ try.functor map (text\= expected)) (try.default false))) -(def: (should-pass! expected parser) +(def: (should_pass! expected parser) (-> Text (/.Parser /.Slice) Bit) - (..should-pass expected (/.slice parser))) + (..should_pass expected (/.slice parser))) -(def: character-classes +(def: character_classes Test ($_ _.and (do {! random.monad} [offset (\ ! map (n.% 50) random.nat) range (\ ! map (|>> (n.% 50) (n.+ 10)) random.nat) #let [limit (n.+ offset range)] - expected (\ ! map (|>> (n.% range) (n.+ offset) text.from-code) random.nat) - out-of-range (case offset - 0 (\ ! map (|>> (n.% 10) inc (n.+ limit) text.from-code) random.nat) - _ (\ ! map (|>> (n.% offset) text.from-code) random.nat))] + expected (\ ! map (|>> (n.% range) (n.+ offset) text.from_code) random.nat) + out_of_range (case offset + 0 (\ ! map (|>> (n.% 10) inc (n.+ limit) text.from_code) random.nat) + _ (\ ! map (|>> (n.% offset) text.from_code) random.nat))] (_.cover [/.range] - (and (..should-pass expected (/.range offset limit)) - (..should-fail out-of-range (/.range offset limit))))) + (and (..should_pass expected (/.range offset limit)) + (..should_fail out_of_range (/.range offset limit))))) (do {! random.monad} - [expected (random.char unicode.ascii/upper-alpha) - invalid (random.filter (|>> (unicode/block.within? unicode/block.basic-latin/upper-alpha) not) + [expected (random.char unicode.ascii/upper_alpha) + invalid (random.filter (|>> (unicode/block.within? unicode/block.basic_latin/upper_alpha) not) (random.char unicode.character))] (_.cover [/.upper] - (and (..should-pass (text.from-code expected) /.upper) - (..should-fail (text.from-code invalid) /.upper)))) + (and (..should_pass (text.from_code expected) /.upper) + (..should_fail (text.from_code invalid) /.upper)))) (do {! random.monad} - [expected (random.char unicode.ascii/lower-alpha) - invalid (random.filter (|>> (unicode/block.within? unicode/block.basic-latin/lower-alpha) not) + [expected (random.char unicode.ascii/lower_alpha) + invalid (random.filter (|>> (unicode/block.within? unicode/block.basic_latin/lower_alpha) not) (random.char unicode.character))] (_.cover [/.lower] - (and (..should-pass (text.from-code expected) /.lower) - (..should-fail (text.from-code invalid) /.lower)))) + (and (..should_pass (text.from_code expected) /.lower) + (..should_fail (text.from_code invalid) /.lower)))) (do {! random.monad} [expected (\ ! map (n.% 10) random.nat) - invalid (random.char (unicode.set [unicode/block.number-forms (list)]))] + invalid (random.char (unicode.set [unicode/block.number_forms (list)]))] (_.cover [/.decimal] - (and (..should-pass (\ n.decimal encode expected) /.decimal) - (..should-fail (text.from-code invalid) /.decimal)))) + (and (..should_pass (\ n.decimal encode expected) /.decimal) + (..should_fail (text.from_code invalid) /.decimal)))) (do {! random.monad} [expected (\ ! map (n.% 8) random.nat) - invalid (random.char (unicode.set [unicode/block.number-forms (list)]))] + invalid (random.char (unicode.set [unicode/block.number_forms (list)]))] (_.cover [/.octal] - (and (..should-pass (\ n.octal encode expected) /.octal) - (..should-fail (text.from-code invalid) /.octal)))) + (and (..should_pass (\ n.octal encode expected) /.octal) + (..should_fail (text.from_code invalid) /.octal)))) (do {! random.monad} [expected (\ ! map (n.% 16) random.nat) - invalid (random.char (unicode.set [unicode/block.number-forms (list)]))] + invalid (random.char (unicode.set [unicode/block.number_forms (list)]))] (_.cover [/.hexadecimal] - (and (..should-pass (\ n.hex encode expected) /.hexadecimal) - (..should-fail (text.from-code invalid) /.hexadecimal)))) + (and (..should_pass (\ n.hex encode expected) /.hexadecimal) + (..should_fail (text.from_code invalid) /.hexadecimal)))) (do {! random.monad} [expected (random.char unicode.ascii/alpha) invalid (random.filter (function (_ char) - (not (or (unicode/block.within? unicode/block.basic-latin/upper-alpha char) - (unicode/block.within? unicode/block.basic-latin/lower-alpha char)))) + (not (or (unicode/block.within? unicode/block.basic_latin/upper_alpha char) + (unicode/block.within? unicode/block.basic_latin/lower_alpha char)))) (random.char unicode.character))] (_.cover [/.alpha] - (and (..should-pass (text.from-code expected) /.alpha) - (..should-fail (text.from-code invalid) /.alpha)))) + (and (..should_pass (text.from_code expected) /.alpha) + (..should_fail (text.from_code invalid) /.alpha)))) (do {! random.monad} - [expected (random.char unicode.ascii/alpha-num) + [expected (random.char unicode.ascii/alpha_num) invalid (random.filter (function (_ char) - (not (or (unicode/block.within? unicode/block.basic-latin/upper-alpha char) - (unicode/block.within? unicode/block.basic-latin/lower-alpha char) - (unicode/block.within? unicode/block.basic-latin/decimal char)))) + (not (or (unicode/block.within? unicode/block.basic_latin/upper_alpha char) + (unicode/block.within? unicode/block.basic_latin/lower_alpha char) + (unicode/block.within? unicode/block.basic_latin/decimal char)))) (random.char unicode.character))] - (_.cover [/.alpha-num] - (and (..should-pass (text.from-code expected) /.alpha-num) - (..should-fail (text.from-code invalid) /.alpha-num)))) + (_.cover [/.alpha_num] + (and (..should_pass (text.from_code expected) /.alpha_num) + (..should_fail (text.from_code invalid) /.alpha_num)))) (do {! random.monad} [expected ($_ random.either (wrap text.tab) - (wrap text.vertical-tab) + (wrap text.vertical_tab) (wrap text.space) - (wrap text.new-line) - (wrap text.carriage-return) - (wrap text.form-feed)) + (wrap text.new_line) + (wrap text.carriage_return) + (wrap text.form_feed)) invalid (|> (random.unicode 1) (random.filter (function (_ char) (not (or (text\= text.tab char) - (text\= text.vertical-tab char) + (text\= text.vertical_tab char) (text\= text.space char) - (text\= text.new-line char) - (text\= text.carriage-return char) - (text\= text.form-feed char))))))] + (text\= text.new_line char) + (text\= text.carriage_return char) + (text\= text.form_feed char))))))] (_.cover [/.space] - (and (..should-pass expected /.space) - (..should-fail invalid /.space)))) + (and (..should_pass expected /.space) + (..should_fail invalid /.space)))) (do {! random.monad} - [#let [num-options 3] + [#let [num_options 3] options (|> (random.char unicode.character) - (random.set n.hash num-options) - (\ ! map (|>> set.to-list - (list\map text.from-code) - (text.join-with "")))) + (random.set n.hash num_options) + (\ ! map (|>> set.to_list + (list\map text.from_code) + (text.join_with "")))) expected (\ ! map (function (_ value) (|> options - (text.nth (n.% num-options value)) + (text.nth (n.% num_options value)) maybe.assume)) random.nat) invalid (random.filter (function (_ char) - (not (text.contains? (text.from-code char) options))) + (not (text.contains? (text.from_code char) options))) (random.char unicode.character))] - (_.cover [/.one-of /.one-of! /.character-should-be] - (and (..should-pass (text.from-code expected) (/.one-of options)) - (..should-fail (text.from-code invalid) (/.one-of options)) - (..should-fail' (text.from-code invalid) (/.one-of options) - /.character-should-be) + (_.cover [/.one_of /.one_of! /.character_should_be] + (and (..should_pass (text.from_code expected) (/.one_of options)) + (..should_fail (text.from_code invalid) (/.one_of options)) + (..should_fail' (text.from_code invalid) (/.one_of options) + /.character_should_be) - (..should-pass! (text.from-code expected) (/.one-of! options)) - (..should-fail (text.from-code invalid) (/.one-of! options)) - (..should-fail' (text.from-code invalid) (/.one-of! options) - /.character-should-be) + (..should_pass! (text.from_code expected) (/.one_of! options)) + (..should_fail (text.from_code invalid) (/.one_of! options)) + (..should_fail' (text.from_code invalid) (/.one_of! options) + /.character_should_be) ))) (do {! random.monad} - [#let [num-options 3] + [#let [num_options 3] options (|> (random.char unicode.character) - (random.set n.hash num-options) - (\ ! map (|>> set.to-list - (list\map text.from-code) - (text.join-with "")))) + (random.set n.hash num_options) + (\ ! map (|>> set.to_list + (list\map text.from_code) + (text.join_with "")))) invalid (\ ! map (function (_ value) (|> options - (text.nth (n.% num-options value)) + (text.nth (n.% num_options value)) maybe.assume)) random.nat) expected (random.filter (function (_ char) - (not (text.contains? (text.from-code char) options))) + (not (text.contains? (text.from_code char) options))) (random.char unicode.character))] - (_.cover [/.none-of /.none-of! /.character-should-not-be] - (and (..should-pass (text.from-code expected) (/.none-of options)) - (..should-fail (text.from-code invalid) (/.none-of options)) - (..should-fail' (text.from-code invalid) (/.none-of options) - /.character-should-not-be) + (_.cover [/.none_of /.none_of! /.character_should_not_be] + (and (..should_pass (text.from_code expected) (/.none_of options)) + (..should_fail (text.from_code invalid) (/.none_of options)) + (..should_fail' (text.from_code invalid) (/.none_of options) + /.character_should_not_be) - (..should-pass! (text.from-code expected) (/.none-of! options)) - (..should-fail (text.from-code invalid) (/.none-of! options)) - (..should-fail' (text.from-code invalid) (/.none-of! options) - /.character-should-not-be) + (..should_pass! (text.from_code expected) (/.none_of! options)) + (..should_fail (text.from_code invalid) (/.none_of! options)) + (..should_fail' (text.from_code invalid) (/.none_of! options) + /.character_should_not_be) ))) )) (def: runs Test - (let [octal! (/.one-of! "01234567")] + (let [octal! (/.one_of! "01234567")] ($_ _.and (do {! random.monad} [left (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat) @@ -217,10 +217,10 @@ (random.filter (n.>= 8)) (\ ! map (\ n.hex encode)))] (_.cover [/.many /.many!] - (and (..should-pass expected (/.many /.octal)) - (..should-fail invalid (/.many /.octal)) + (and (..should_pass expected (/.many /.octal)) + (..should_fail invalid (/.many /.octal)) - (..should-pass! expected (/.many! octal!))))) + (..should_pass! expected (/.many! octal!))))) (do {! random.monad} [left (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat) right (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat) @@ -230,64 +230,64 @@ (random.filter (n.>= 8)) (\ ! map (\ n.hex encode)))] (_.cover [/.some /.some!] - (and (..should-pass expected (/.some /.octal)) - (..should-pass "" (/.some /.octal)) - (..should-fail invalid (/.some /.octal)) + (and (..should_pass expected (/.some /.octal)) + (..should_pass "" (/.some /.octal)) + (..should_fail invalid (/.some /.octal)) - (..should-pass! expected (/.some! octal!)) - (..should-pass! "" (/.some! octal!))))) + (..should_pass! expected (/.some! octal!)) + (..should_pass! "" (/.some! octal!))))) (do {! random.monad} [#let [octal (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat)] first octal second octal third octal] (_.cover [/.exactly /.exactly!] - (and (..should-pass (format first second) (/.exactly 2 /.octal)) - (..should-fail (format first second third) (/.exactly 2 /.octal)) - (..should-fail (format first) (/.exactly 2 /.octal)) + (and (..should_pass (format first second) (/.exactly 2 /.octal)) + (..should_fail (format first second third) (/.exactly 2 /.octal)) + (..should_fail (format first) (/.exactly 2 /.octal)) - (..should-pass! (format first second) (/.exactly! 2 octal!)) - (..should-fail (format first second third) (/.exactly! 2 octal!)) - (..should-fail (format first) (/.exactly! 2 octal!))))) + (..should_pass! (format first second) (/.exactly! 2 octal!)) + (..should_fail (format first second third) (/.exactly! 2 octal!)) + (..should_fail (format first) (/.exactly! 2 octal!))))) (do {! random.monad} [#let [octal (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat)] first octal second octal third octal] - (_.cover [/.at-most /.at-most!] - (and (..should-pass (format first second) (/.at-most 2 /.octal)) - (..should-pass (format first) (/.at-most 2 /.octal)) - (..should-fail (format first second third) (/.at-most 2 /.octal)) + (_.cover [/.at_most /.at_most!] + (and (..should_pass (format first second) (/.at_most 2 /.octal)) + (..should_pass (format first) (/.at_most 2 /.octal)) + (..should_fail (format first second third) (/.at_most 2 /.octal)) - (..should-pass! (format first second) (/.at-most! 2 octal!)) - (..should-pass! (format first) (/.at-most! 2 octal!)) - (..should-fail (format first second third) (/.at-most! 2 octal!))))) + (..should_pass! (format first second) (/.at_most! 2 octal!)) + (..should_pass! (format first) (/.at_most! 2 octal!)) + (..should_fail (format first second third) (/.at_most! 2 octal!))))) (do {! random.monad} [#let [octal (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat)] first octal second octal third octal] - (_.cover [/.at-least /.at-least!] - (and (..should-pass (format first second) (/.at-least 2 /.octal)) - (..should-pass (format first second third) (/.at-least 2 /.octal)) - (..should-fail (format first) (/.at-least 2 /.octal)) + (_.cover [/.at_least /.at_least!] + (and (..should_pass (format first second) (/.at_least 2 /.octal)) + (..should_pass (format first second third) (/.at_least 2 /.octal)) + (..should_fail (format first) (/.at_least 2 /.octal)) - (..should-pass! (format first second) (/.at-least! 2 octal!)) - (..should-pass! (format first second third) (/.at-least! 2 octal!)) - (..should-fail (format first) (/.at-least! 2 octal!))))) + (..should_pass! (format first second) (/.at_least! 2 octal!)) + (..should_pass! (format first second third) (/.at_least! 2 octal!)) + (..should_fail (format first) (/.at_least! 2 octal!))))) (do {! random.monad} [#let [octal (\ ! map (|>> (n.% 8) (\ n.octal encode)) random.nat)] first octal second octal third octal] (_.cover [/.between /.between!] - (and (..should-pass (format first second) (/.between 2 3 /.octal)) - (..should-pass (format first second third) (/.between 2 3 /.octal)) - (..should-fail (format first) (/.between 2 3 /.octal)) + (and (..should_pass (format first second) (/.between 2 3 /.octal)) + (..should_pass (format first second third) (/.between 2 3 /.octal)) + (..should_fail (format first) (/.between 2 3 /.octal)) - (..should-pass! (format first second) (/.between! 2 3 octal!)) - (..should-pass! (format first second third) (/.between! 2 3 octal!)) - (..should-fail (format first) (/.between! 2 3 octal!))))) + (..should_pass! (format first second) (/.between! 2 3 octal!)) + (..should_pass! (format first second third) (/.between! 2 3 octal!)) + (..should_fail (format first) (/.between! 2 3 octal!))))) ))) (def: #export test @@ -309,42 +309,42 @@ expected (random.unicode size) dummy (|> (random.unicode size) (random.filter (|>> (text\= expected) not)))] - (_.cover [/.this /.cannot-match] + (_.cover [/.this /.cannot_match] (and (|> (/.run (/.this expected) expected) (!expect (#try.Success []))) (|> (/.run (/.this expected) dummy) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-match error))))))) - (_.cover [/.Slice /.slice /.cannot-slice] + (exception.match? /.cannot_match error))))))) + (_.cover [/.Slice /.slice /.cannot_slice] (|> "" (/.run (/.slice /.any!)) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-slice error))))) + (exception.match? /.cannot_slice error))))) (do {! random.monad} [expected (random.unicode 1)] (_.cover [/.any /.any!] - (and (..should-pass expected /.any) - (..should-fail "" /.any) + (and (..should_pass expected /.any) + (..should_fail "" /.any) - (..should-pass! expected /.any!) - (..should-fail "" /.any!)))) + (..should_pass! expected /.any!) + (..should_fail "" /.any!)))) (do {! random.monad} [expected (random.unicode 1)] - (_.cover [/.peek /.cannot-parse] - (and (..should-pass expected (<>.before /.any /.peek)) + (_.cover [/.peek /.cannot_parse] + (and (..should_pass expected (<>.before /.any /.peek)) (|> "" (/.run (<>.before /.any /.peek)) (!expect (^multi (#try.Failure error) - (exception.match? /.cannot-parse error))))))) + (exception.match? /.cannot_parse error))))))) (do {! random.monad} [dummy (random.unicode 1)] - (_.cover [/.unconsumed-input] + (_.cover [/.unconsumed_input] (|> (format dummy dummy) (/.run /.any) (!expect (^multi (#try.Failure error) - (exception.match? /.unconsumed-input error)))))) + (exception.match? /.unconsumed_input error)))))) (do {! random.monad} [sample (random.unicode 1)] (_.cover [/.Offset /.offset] @@ -359,12 +359,12 @@ [left (random.unicode 1) right (random.unicode 1) #let [input (format left right)]] - (_.cover [/.get-input] + (_.cover [/.get_input] (|> input (/.run (do <>.monad - [pre /.get-input + [pre /.get_input _ /.any - post /.get-input + post /.get_input _ /.any] (wrap (and (text\= input pre) (text\= right post))))) @@ -395,47 +395,47 @@ (!expect (^multi (#try.Success actual) (text\= expected actual)))))) (do {! random.monad} - [invalid (random.ascii/upper-alpha 1) - expected (random.filter (|>> (unicode/block.within? unicode/block.basic-latin/upper-alpha) + [invalid (random.ascii/upper_alpha 1) + expected (random.filter (|>> (unicode/block.within? unicode/block.basic_latin/upper_alpha) not) (random.char unicode.character)) - #let [upper! (/.one-of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]] - (_.cover [/.not /.not! /.expected-to-fail] - (and (..should-pass (text.from-code expected) (/.not /.upper)) + #let [upper! (/.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]] + (_.cover [/.not /.not! /.expected_to_fail] + (and (..should_pass (text.from_code expected) (/.not /.upper)) (|> invalid (/.run (/.not /.upper)) (!expect (^multi (#try.Failure error) - (exception.match? /.expected-to-fail error)))) + (exception.match? /.expected_to_fail error)))) - (..should-pass! (text.from-code expected) (/.not! upper!)) + (..should_pass! (text.from_code expected) (/.not! upper!)) (|> invalid (/.run (/.not! upper!)) (!expect (^multi (#try.Failure error) - (exception.match? /.expected-to-fail error))))))) + (exception.match? /.expected_to_fail error))))))) (do {! random.monad} - [upper (random.ascii/upper-alpha 1) - lower (random.ascii/lower-alpha 1) + [upper (random.ascii/upper_alpha 1) + lower (random.ascii/lower_alpha 1) invalid (random.filter (function (_ char) - (not (or (unicode/block.within? unicode/block.basic-latin/upper-alpha char) - (unicode/block.within? unicode/block.basic-latin/lower-alpha char)))) + (not (or (unicode/block.within? unicode/block.basic_latin/upper_alpha char) + (unicode/block.within? unicode/block.basic_latin/lower_alpha char)))) (random.char unicode.character)) - #let [upper! (/.one-of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ") - lower! (/.one-of! "abcdefghijklmnopqrstuvwxyz")]] + #let [upper! (/.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ") + lower! (/.one_of! "abcdefghijklmnopqrstuvwxyz")]] (_.cover [/.and /.and!] - (and (..should-pass (format upper lower) (/.and /.upper /.lower)) - (..should-fail (format (text.from-code invalid) lower) (/.and /.upper /.lower)) - (..should-fail (format upper (text.from-code invalid)) (/.and /.upper /.lower)) + (and (..should_pass (format upper lower) (/.and /.upper /.lower)) + (..should_fail (format (text.from_code invalid) lower) (/.and /.upper /.lower)) + (..should_fail (format upper (text.from_code invalid)) (/.and /.upper /.lower)) - (..should-pass! (format upper lower) (/.and! upper! lower!)) - (..should-fail (format (text.from-code invalid) lower) (/.and! upper! lower!)) - (..should-fail (format upper (text.from-code invalid)) (/.and! upper! lower!))))) + (..should_pass! (format upper lower) (/.and! upper! lower!)) + (..should_fail (format (text.from_code invalid) lower) (/.and! upper! lower!)) + (..should_fail (format upper (text.from_code invalid)) (/.and! upper! lower!))))) (do {! random.monad} [expected (random.unicode 1) invalid (random.unicode 1)] - (_.cover [/.satisfies /.character-does-not-satisfy-predicate] - (and (..should-pass expected (/.satisfies (function.constant true))) - (..should-fail' invalid (/.satisfies (function.constant false)) - /.character-does-not-satisfy-predicate)))) - ..character-classes + (_.cover [/.satisfies /.character_does_not_satisfy_predicate] + (and (..should_pass expected (/.satisfies (function.constant true))) + (..should_fail' invalid (/.satisfies (function.constant false)) + /.character_does_not_satisfy_predicate)))) + ..character_classes ..runs ))) diff --git a/stdlib/source/test/lux/control/parser/type.lux b/stdlib/source/test/lux/control/parser/type.lux index f703d38a7..47cdac08f 100644 --- a/stdlib/source/test/lux/control/parser/type.lux +++ b/stdlib/source/test/lux/control/parser/type.lux @@ -29,13 +29,13 @@ (def: primitive (Random Type) - (|> (random.ascii/alpha-num 1) + (|> (random.ascii/alpha_num 1) (\ random.monad map (function (_ name) (#.Primitive name (list)))))) (def: matches Test - (<| (_.for [/.types-do-not-match]) + (<| (_.for [/.types_do_not_match]) (do {! random.monad} [expected ..primitive dummy (random.filter (|>> (type\= expected) not) @@ -46,7 +46,7 @@ (!expect (#try.Success []))) (|> (/.run (/.exactly expected) dummy) (!expect (^multi (#try.Failure error) - (exception.match? /.types-do-not-match error)))))) + (exception.match? /.types_do_not_match error)))))) (_.cover [/.sub] (and (|> (/.run (/.sub expected) expected) (!expect (#try.Success []))) @@ -56,7 +56,7 @@ (!expect (#try.Success []))) (|> (/.run (/.sub expected) dummy) (!expect (^multi (#try.Failure error) - (exception.match? /.types-do-not-match error)))))) + (exception.match? /.types_do_not_match error)))))) (_.cover [/.super] (and (|> (/.run (/.super expected) expected) (!expect (#try.Success []))) @@ -66,55 +66,55 @@ (!expect (#try.Success []))) (|> (/.run (/.super expected) dummy) (!expect (^multi (#try.Failure error) - (exception.match? /.types-do-not-match error)))))) + (exception.match? /.types_do_not_match error)))))) ))) (def: aggregate Test (do {! random.monad} - [expected-left ..primitive - expected-middle ..primitive - expected-right ..primitive] + [expected_left ..primitive + expected_middle ..primitive + expected_right ..primitive] (`` ($_ _.and - (~~ (template [<parser> <exception> <good-constructor> <bad-constructor>] + (~~ (template [<parser> <exception> <good_constructor> <bad_constructor>] [(_.cover [<parser> <exception>] (and (|> (/.run (<parser> ($_ //.and /.any /.any /.any)) - (<good-constructor> (list expected-left expected-middle expected-right))) - (!expect (^multi (#try.Success [actual-left actual-middle actual-right]) - (and (type\= expected-left actual-left) - (type\= expected-middle actual-middle) - (type\= expected-right actual-right))))) + (<good_constructor> (list expected_left expected_middle expected_right))) + (!expect (^multi (#try.Success [actual_left actual_middle actual_right]) + (and (type\= expected_left actual_left) + (type\= expected_middle actual_middle) + (type\= expected_right actual_right))))) (|> (/.run (<parser> ($_ //.and /.any /.any /.any)) - (<bad-constructor> (list expected-left expected-middle expected-right))) + (<bad_constructor> (list expected_left expected_middle expected_right))) (!expect (^multi (#try.Failure error) (exception.match? <exception> error))))))] - [/.variant /.not-variant type.variant type.tuple] - [/.tuple /.not-tuple type.tuple type.variant] + [/.variant /.not_variant type.variant type.tuple] + [/.tuple /.not_tuple type.tuple type.variant] )) - (_.cover [/.function /.not-function] + (_.cover [/.function /.not_function] (and (|> (/.run (/.function ($_ //.and /.any /.any) /.any) - (type.function (list expected-left expected-middle) expected-right)) - (!expect (^multi (#try.Success [[actual-left actual-middle] actual-right]) - (and (type\= expected-left actual-left) - (type\= expected-middle actual-middle) - (type\= expected-right actual-right))))) + (type.function (list expected_left expected_middle) expected_right)) + (!expect (^multi (#try.Success [[actual_left actual_middle] actual_right]) + (and (type\= expected_left actual_left) + (type\= expected_middle actual_middle) + (type\= expected_right actual_right))))) (|> (/.run (/.function ($_ //.and /.any /.any) /.any) - (type.variant (list expected-left expected-middle expected-right))) + (type.variant (list expected_left expected_middle expected_right))) (!expect (^multi (#try.Failure error) - (exception.match? /.not-function error)))))) - (_.cover [/.apply /.not-application] + (exception.match? /.not_function error)))))) + (_.cover [/.apply /.not_application] (and (|> (/.run (/.apply ($_ //.and /.any /.any /.any)) - (type.application (list expected-middle expected-right) expected-left)) - (!expect (^multi (#try.Success [actual-left actual-middle actual-right]) - (and (type\= expected-left actual-left) - (type\= expected-middle actual-middle) - (type\= expected-right actual-right))))) + (type.application (list expected_middle expected_right) expected_left)) + (!expect (^multi (#try.Success [actual_left actual_middle actual_right]) + (and (type\= expected_left actual_left) + (type\= expected_middle actual_middle) + (type\= expected_right actual_right))))) (|> (/.run (/.apply ($_ //.and /.any /.any /.any)) - (type.variant (list expected-left expected-middle expected-right))) + (type.variant (list expected_left expected_middle expected_right))) (!expect (^multi (#try.Failure error) - (exception.match? /.not-application error)))))) + (exception.match? /.not_application error)))))) )))) (def: parameter @@ -122,40 +122,40 @@ (do random.monad [quantification ..primitive argument ..primitive - not-parameter ..primitive + not_parameter ..primitive parameter random.nat] ($_ _.and - (_.cover [/.not-parameter] - (|> (/.run /.parameter not-parameter) + (_.cover [/.not_parameter] + (|> (/.run /.parameter not_parameter) (!expect (^multi (#try.Failure error) - (exception.match? /.not-parameter error))))) - (_.cover [/.unknown-parameter] + (exception.match? /.not_parameter error))))) + (_.cover [/.unknown_parameter] (|> (/.run /.parameter (#.Parameter parameter)) (!expect (^multi (#try.Failure error) - (exception.match? /.unknown-parameter error))))) - (_.cover [/.with-extension] - (|> (/.run (<| (/.with-extension quantification) - (/.with-extension argument) + (exception.match? /.unknown_parameter error))))) + (_.cover [/.with_extension] + (|> (/.run (<| (/.with_extension quantification) + (/.with_extension argument) /.any) - not-parameter) + not_parameter) (!expect (^multi (#try.Success [quantification\\binding argument\\binding actual]) - (is? not-parameter actual))))) + (is? not_parameter actual))))) (_.cover [/.parameter] - (|> (/.run (<| (/.with-extension quantification) - (/.with-extension argument) + (|> (/.run (<| (/.with_extension quantification) + (/.with_extension argument) /.parameter) (#.Parameter 0)) (!expect (#try.Success [quantification\\binding argument\\binding _])))) - (_.cover [/.wrong-parameter] - (|> (/.run (<| (/.with-extension quantification) - (/.with-extension argument) + (_.cover [/.wrong_parameter] + (|> (/.run (<| (/.with_extension quantification) + (/.with_extension argument) (/.parameter! 1)) (#.Parameter 0)) (!expect (^multi (#try.Failure error) - (exception.match? /.wrong-parameter error))))) + (exception.match? /.wrong_parameter error))))) (_.cover [/.parameter!] - (|> (/.run (<| (/.with-extension quantification) - (/.with-extension argument) + (|> (/.run (<| (/.with_extension quantification) + (/.with_extension argument) (/.parameter! 0)) (#.Parameter 0)) (!expect (#try.Success [quantification\\binding argument\\binding _])))) @@ -164,24 +164,24 @@ (def: polymorphic Test (do {! random.monad} - [not-polymorphic ..primitive - expected-inputs (\ ! map (|>> (n.% 10) inc) random.nat)] + [not_polymorphic ..primitive + expected_inputs (\ ! map (|>> (n.% 10) inc) random.nat)] ($_ _.and - (_.cover [/.not-polymorphic] + (_.cover [/.not_polymorphic] (and (|> (/.run (/.polymorphic /.any) - not-polymorphic) + not_polymorphic) (!expect (^multi (#try.Failure error) - (exception.match? /.not-polymorphic error)))) + (exception.match? /.not_polymorphic error)))) (|> (/.run (/.polymorphic /.any) - (type.univ-q 0 not-polymorphic)) + (type.univ_q 0 not_polymorphic)) (!expect (^multi (#try.Failure error) - (exception.match? /.not-polymorphic error)))))) + (exception.match? /.not_polymorphic error)))))) (_.cover [/.polymorphic] (|> (/.run (/.polymorphic /.any) - (type.univ-q expected-inputs not-polymorphic)) - (!expect (^multi (#try.Success [g!poly actual-inputs bodyT]) - (and (n.= expected-inputs (list.size actual-inputs)) - (is? not-polymorphic bodyT)))))) + (type.univ_q expected_inputs not_polymorphic)) + (!expect (^multi (#try.Success [g!poly actual_inputs bodyT]) + (and (n.= expected_inputs (list.size actual_inputs)) + (is? not_polymorphic bodyT)))))) ))) (def: #export test @@ -197,7 +197,7 @@ (type\= expected actual)))))) (do {! random.monad} [expected ..primitive] - (_.cover [/.peek /.unconsumed-input] + (_.cover [/.peek /.unconsumed_input] (and (|> (/.run (do //.monad [actual /.peek _ /.any] @@ -207,17 +207,17 @@ (type\= expected actual)))) (|> (/.run /.peek expected) (!expect (^multi (#try.Failure error) - (exception.match? /.unconsumed-input error))))))) + (exception.match? /.unconsumed_input error))))))) (do {! random.monad} [expected ..primitive] - (_.cover [/.empty-input] + (_.cover [/.empty_input] (`` (and (~~ (template [<parser>] [(|> (/.run (do //.monad [_ /.any] <parser>) expected) (!expect (^multi (#try.Failure error) - (exception.match? /.empty-input error))))] + (exception.match? /.empty_input error))))] [/.any] [/.peek] @@ -246,21 +246,21 @@ (type\= expected actual)))))) (do {! random.monad} [expected random.nat] - (_.cover [/.existential /.not-existential] + (_.cover [/.existential /.not_existential] (|> (/.run /.existential (#.Ex expected)) (!expect (^multi (#try.Success actual) (n.= expected actual)))))) (do {! random.monad} - [expected-name (random.and (random.ascii/alpha-num 1) - (random.ascii/alpha-num 1)) - expected-type ..primitive] - (_.cover [/.named /.not-named] + [expected_name (random.and (random.ascii/alpha_num 1) + (random.ascii/alpha_num 1)) + expected_type ..primitive] + (_.cover [/.named /.not_named] (|> (/.run /.named - (#.Named expected-name expected-type)) - (!expect (^multi (#try.Success [actual-name actual-type]) - (and (name\= expected-name actual-name) - (type\= expected-type actual-type))))))) + (#.Named expected_name expected_type)) + (!expect (^multi (#try.Success [actual_name actual_type]) + (and (name\= expected_name actual_name) + (type\= expected_type actual_type))))))) ..aggregate ..matches ..parameter diff --git a/stdlib/source/test/lux/control/parser/xml.lux b/stdlib/source/test/lux/control/parser/xml.lux index c17faa6b0..6d6126e8f 100644 --- a/stdlib/source/test/lux/control/parser/xml.lux +++ b/stdlib/source/test/lux/control/parser/xml.lux @@ -34,7 +34,7 @@ false)) (template: (!failure <exception> <cases>) - (with-expansions [<<cases>> (template.splice <cases>)] + (with_expansions [<<cases>> (template.splice <cases>)] (do {! random.monad} [expected (random.ascii/alpha 1)] (_.cover [<exception>] @@ -45,13 +45,13 @@ <<cases>>)))))))) -(def: random-label +(def: random_label (Random Name) (random.and (random.ascii/alpha 1) (random.ascii/alpha 1))) -(def: random-tag ..random-label) -(def: random-attribute ..random-label) +(def: random_tag ..random_label) +(def: random_attribute ..random_label) (def: #export test Test @@ -64,7 +64,7 @@ (|> (/.run /.text (#xml.Text expected)) (!expect (^multi (#try.Success actual) (text\= expected actual)))))) - (!failure /.unconsumed-inputs + (!failure /.unconsumed_inputs [[(//\wrap expected) (#xml.Text expected)]]) (do {! random.monad} @@ -73,7 +73,7 @@ (|> (/.run /.ignore (#xml.Text expected)) (!expect (#try.Success []))))) (do {! random.monad} - [expected ..random-tag] + [expected ..random_tag] (_.cover [/.tag] (|> (/.run (do //.monad [actual /.tag @@ -82,31 +82,31 @@ (#xml.Node expected (dictionary.new name.hash) (list))) (!expect (#try.Success #1))))) (do {! random.monad} - [expected ..random-tag] + [expected ..random_tag] (_.cover [/.node] (|> (/.run (do //.monad [_ (/.node expected)] /.ignore) (#xml.Node expected (dictionary.new name.hash) (list))) (!expect (#try.Success []))))) - (!failure /.wrong-tag + (!failure /.wrong_tag [[(/.node ["" expected]) (#xml.Node [expected ""] (dictionary.new name.hash) (list))]]) (do {! random.monad} - [expected-tag ..random-tag - expected-attribute ..random-attribute - expected-value (random.ascii/alpha 1)] + [expected_tag ..random_tag + expected_attribute ..random_attribute + expected_value (random.ascii/alpha 1)] (_.cover [/.attribute] (|> (/.run (do //.monad - [_ (/.node expected-tag) - _ (/.attribute expected-attribute)] + [_ (/.node expected_tag) + _ (/.attribute expected_attribute)] /.ignore) - (#xml.Node expected-tag + (#xml.Node expected_tag (|> (dictionary.new name.hash) - (dictionary.put expected-attribute expected-value)) + (dictionary.put expected_attribute expected_value)) (list))) (!expect (#try.Success []))))) - (!failure /.unknown-attribute + (!failure /.unknown_attribute [[(do //.monad [_ (/.attribute ["" expected])] /.ignore) @@ -115,7 +115,7 @@ (dictionary.put [expected ""] expected)) (list))]]) (do {! random.monad} - [expected ..random-tag] + [expected ..random_tag] (_.cover [/.children] (|> (/.run (do {! //.monad} [_ (/.node expected)] @@ -129,7 +129,7 @@ (dictionary.new name.hash) (list))))) (!expect (#try.Success []))))) - (!failure /.empty-input + (!failure /.empty_input [[(do //.monad [_ /.ignore] /.ignore) @@ -160,7 +160,7 @@ (list (#xml.Node [expected expected] (dictionary.new name.hash) (list))))]]) - (!failure /.unexpected-input + (!failure /.unexpected_input [[/.text (#xml.Node [expected expected] (dictionary.new name.hash) (list))] [(do //.monad @@ -182,10 +182,10 @@ [#let [node (: (-> xml.Tag (List xml.XML) xml.XML) (function (_ tag children) (#xml.Node tag (dictionary.new name.hash) children)))] - parent ..random-tag - right ..random-tag + parent ..random_tag + right ..random_tag wrong (random.filter (|>> (name\= right) not) - ..random-tag) + ..random_tag) #let [parser (/.children (do //.monad [_ (/.somewhere (/.node right)) |