diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/macro/code.lux | 84 | ||||
-rw-r--r-- | stdlib/source/test/lux/macro/poly/equivalence.lux | 36 | ||||
-rw-r--r-- | stdlib/source/test/lux/macro/poly/functor.lux | 10 | ||||
-rw-r--r-- | stdlib/source/test/lux/macro/poly/json.lux | 28 | ||||
-rw-r--r-- | stdlib/source/test/lux/macro/syntax.lux | 24 | ||||
-rw-r--r-- | stdlib/source/test/lux/macro/syntax/common.lux | 42 | ||||
-rw-r--r-- | stdlib/source/test/lux/macro/syntax/common/definition.lux | 24 | ||||
-rw-r--r-- | stdlib/source/test/lux/macro/template.lux | 16 |
8 files changed, 132 insertions, 132 deletions
diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux index 8f6dc91d5..cbaa5aee7 100644 --- a/stdlib/source/test/lux/macro/code.lux +++ b/stdlib/source/test/lux/macro/code.lux @@ -27,21 +27,21 @@ {1 ["." /]}) -(def: random-text +(def: random_text (Random Text) (random.ascii/alpha 10)) -(def: random-name +(def: random_name (Random Name) - (random.and ..random-text ..random-text)) + (random.and ..random_text ..random_text)) -(def: (random-sequence random) +(def: (random_sequence random) (All [a] (-> (Random a) (Random (List a)))) (do {! random.monad} [size (|> random.nat (\ ! map (n.% 3)))] (random.list size random))) -(def: (random-record random) +(def: (random_record random) (All [a] (-> (Random a) (Random (List [a a])))) (do {! random.monad} [size (|> random.nat (\ ! map (n.% 3)))] @@ -56,39 +56,39 @@ (random\map /.nat random.nat) (random\map /.int random.int) (random\map /.rev random.rev) - (random\map /.frac random.safe-frac) - (random\map /.text ..random-text) - (random\map /.identifier ..random-name) - (random\map /.tag ..random-name) - (random\map /.form (..random-sequence random)) - (random\map /.tuple (..random-sequence random)) - (random\map /.record (..random-record random)) + (random\map /.frac random.safe_frac) + (random\map /.text ..random_text) + (random\map /.identifier ..random_name) + (random\map /.tag ..random_name) + (random\map /.form (..random_sequence random)) + (random\map /.tuple (..random_sequence random)) + (random\map /.record (..random_record random)) )))) -(def: (read source-code) +(def: (read source_code) (-> Text (Try Code)) (let [parse (syntax.parse "" - syntax.no-aliases - (text.size source-code)) + syntax.no_aliases + (text.size source_code)) start (: Source - [location.dummy 0 source-code])] + [location.dummy 0 source_code])] (case (parse start) (#.Left [end error]) (#try.Failure error) - (#.Right [end lux-code]) - (#try.Success lux-code)))) + (#.Right [end lux_code]) + (#try.Success lux_code)))) -(def: (replace-simulation [original substitute]) +(def: (replace_simulation [original substitute]) (-> [Code Code] (Random [Code Code])) (random.rec - (function (_ replace-simulation) - (let [for-sequence (: (-> (-> (List Code) Code) (Random [Code Code])) - (function (_ to-code) + (function (_ replace_simulation) + (let [for_sequence (: (-> (-> (List Code) Code) (Random [Code Code])) + (function (_ to_code) (do {! random.monad} - [parts (..random-sequence replace-simulation)] - (wrap [(to-code (list\map product.left parts)) - (to-code (list\map product.right parts))]))))] + [parts (..random_sequence replace_simulation)] + (wrap [(to_code (list\map product.left parts)) + (to_code (list\map product.right parts))]))))] ($_ random.either (random\wrap [original substitute]) (do {! random.monad} @@ -98,15 +98,15 @@ (random\map /.nat random.nat) (random\map /.int random.int) (random\map /.rev random.rev) - (random\map /.frac random.safe-frac) - (random\map /.text ..random-text) - (random\map /.identifier ..random-name) - (random\map /.tag ..random-name)))] + (random\map /.frac random.safe_frac) + (random\map /.text ..random_text) + (random\map /.identifier ..random_name) + (random\map /.tag ..random_name)))] (wrap [sample sample])) - (for-sequence /.form) - (for-sequence /.tuple) + (for_sequence /.form) + (for_sequence /.tuple) (do {! random.monad} - [parts (..random-sequence replace-simulation)] + [parts (..random_sequence replace_simulation)] (wrap [(/.record (let [parts' (list\map product.left parts)] (list.zip/2 parts' parts'))) (/.record (let [parts' (list\map product.right parts)] @@ -141,13 +141,13 @@ [/.nat random.nat #.Nat] [/.int random.int #.Int] [/.rev random.rev #.Rev] - [/.frac random.safe-frac #.Frac] - [/.text ..random-text #.Text] - [/.tag ..random-name #.Tag] - [/.identifier ..random-name #.Identifier] - [/.form (..random-sequence ..random) #.Form] - [/.tuple (..random-sequence ..random) #.Tuple] - [/.record (..random-record ..random) #.Record])) + [/.frac random.safe_frac #.Frac] + [/.text ..random_text #.Text] + [/.tag ..random_name #.Tag] + [/.identifier ..random_name #.Identifier] + [/.form (..random_sequence ..random) #.Form] + [/.tuple (..random_sequence ..random) #.Tuple] + [/.record (..random_record ..random) #.Record])) (~~ (template [<coverage> <random> <tag>] [(do {! random.monad} [expected <random>] @@ -165,12 +165,12 @@ (<coverage> expected))) ))] - [/.local-tag ..random-text #.Tag] - [/.local-identifier ..random-text #.Identifier] + [/.local_tag ..random_text #.Tag] + [/.local_identifier ..random_text #.Identifier] ))))) (do {! random.monad} [[original substitute] (random.and ..random ..random) - [sample expected] (..replace-simulation [original substitute])] + [sample expected] (..replace_simulation [original substitute])] (_.cover [/.replace] (\ /.equivalence = expected diff --git a/stdlib/source/test/lux/macro/poly/equivalence.lux b/stdlib/source/test/lux/macro/poly/equivalence.lux index 16903ebc2..51315ec1e 100644 --- a/stdlib/source/test/lux/macro/poly/equivalence.lux +++ b/stdlib/source/test/lux/macro/poly/equivalence.lux @@ -41,43 +41,43 @@ #tuple [Int Frac Text] #recursive Recursive}) -(def: gen-recursive +(def: gen_recursive (Random Recursive) - (random.rec (function (_ gen-recursive) - (random.or random.safe-frac - (random.and random.safe-frac - gen-recursive))))) + (random.rec (function (_ gen_recursive) + (random.or random.safe_frac + (random.and random.safe_frac + gen_recursive))))) -(def: gen-record +(def: gen_record (Random Record) (do {! random.monad} [size (\ ! map (n.% 2) random.nat) - #let [gen-int (|> random.int (\ ! map (|>> i.abs (i.% +1,000,000))))]] + #let [gen_int (|> random.int (\ ! map (|>> i.abs (i.% +1,000,000))))]] ($_ random.and random.bit - gen-int - random.safe-frac + gen_int + random.safe_frac (random.unicode size) - (random.maybe gen-int) - (random.list size gen-int) + (random.maybe gen_int) + (random.list size gen_int) ($_ random.or random.bit - gen-int - random.safe-frac) + gen_int + random.safe_frac) ($_ random.and - gen-int - random.safe-frac + gen_int + random.safe_frac (random.unicode size)) - gen-recursive))) + gen_recursive))) (derived: equivalence (/.equivalence Record)) (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) (do random.monad - [sample gen-record + [sample gen_record #let [(^open "/\.") ..equivalence]] (_.test "Every instance equals itself." (/\= sample sample))))) diff --git a/stdlib/source/test/lux/macro/poly/functor.lux b/stdlib/source/test/lux/macro/poly/functor.lux index 85d24bc5b..3f2b4db50 100644 --- a/stdlib/source/test/lux/macro/poly/functor.lux +++ b/stdlib/source/test/lux/macro/poly/functor.lux @@ -15,13 +15,13 @@ [macro [poly (#+ derived:)]]]) -(derived: maybe-functor (/.functor .Maybe)) -(derived: list-functor (/.functor .List)) -(derived: state-functor (/.functor state.State)) -(derived: identity-functor (/.functor identity.Identity)) +(derived: maybe_functor (/.functor .Maybe)) +(derived: list_functor (/.functor .List)) +(derived: state_functor (/.functor state.State)) +(derived: identity_functor (/.functor identity.Identity)) (def: #export test Test - (<| (_.context (%.name (name-of /._))) + (<| (_.context (%.name (name_of /._))) (_.test "Can derive functors automatically." true))) diff --git a/stdlib/source/test/lux/macro/poly/json.lux b/stdlib/source/test/lux/macro/poly/json.lux index 4b6718577..b6b3a29e2 100644 --- a/stdlib/source/test/lux/macro/poly/json.lux +++ b/stdlib/source/test/lux/macro/poly/json.lux @@ -75,32 +75,32 @@ #date tda.Date #grams (unit.Qty unit.Gram)}) -(def: gen-recursive +(def: gen_recursive (Random Recursive) (random.rec - (function (_ gen-recursive) - (random.or random.safe-frac - (random.and random.safe-frac - gen-recursive))))) + (function (_ gen_recursive) + (random.or random.safe_frac + (random.and random.safe_frac + gen_recursive))))) (def: qty (All [unit] (Random (unit.Qty unit))) (|> random.int (\ random.monad map unit.in))) -(def: gen-record +(def: gen_record (Random Record) (do {! random.monad} [size (\ ! map (n.% 2) random.nat)] ($_ random.and random.bit - random.safe-frac + random.safe_frac (random.unicode size) - (random.maybe random.safe-frac) - (random.list size random.safe-frac) - (random.dictionary text.hash size (random.unicode size) random.safe-frac) - ($_ random.or random.bit (random.unicode size) random.safe-frac) - ($_ random.and random.bit (random.unicode size) random.safe-frac) - ..gen-recursive + (random.maybe random.safe_frac) + (random.list size random.safe_frac) + (random.dictionary text.hash size (random.unicode size) random.safe_frac) + ($_ random.or random.bit (random.unicode size) random.safe_frac) + ($_ random.and random.bit (random.unicode size) random.safe_frac) + ..gen_recursive ## _instant.instant ## _duration.duration _date.date @@ -117,4 +117,4 @@ Test (<| (_.covering /._) (_.for [/.codec] - ($codec.spec ..equivalence ..codec ..gen-record)))) + ($codec.spec ..equivalence ..codec ..gen_record)))) diff --git a/stdlib/source/test/lux/macro/syntax.lux b/stdlib/source/test/lux/macro/syntax.lux index 90efa671f..316734d36 100644 --- a/stdlib/source/test/lux/macro/syntax.lux +++ b/stdlib/source/test/lux/macro/syntax.lux @@ -68,7 +68,7 @@ (~' _) #0))))) -(def: simple-values +(def: simple_values Test (`` ($_ _.and (~~ (template [<assertion> <value> <ctor> <Equivalence> <get>] @@ -82,25 +82,25 @@ ["Can parse Int syntax." +123 code.int int.equivalence s.int] ["Can parse Rev syntax." .123 code.rev rev.equivalence s.rev] ["Can parse Frac syntax." +123.0 code.frac frac.equivalence s.frac] - ["Can parse Text syntax." text.new-line code.text text.equivalence s.text] + ["Can parse Text syntax." text.new_line code.text text.equivalence s.text] ["Can parse Identifier syntax." ["yolo" "lol"] code.identifier name.equivalence s.identifier] ["Can parse Tag syntax." ["yolo" "lol"] code.tag name.equivalence s.tag] )) (_.test "Can parse identifiers belonging to the current namespace." (and (match "yolo" - (p.run s.local-identifier - (list (code.local-identifier "yolo")))) - (fails? (p.run s.local-identifier + (p.run s.local_identifier + (list (code.local_identifier "yolo")))) + (fails? (p.run s.local_identifier (list (code.identifier ["yolo" "lol"])))))) (_.test "Can parse tags belonging to the current namespace." (and (match "yolo" - (p.run s.local-tag - (list (code.local-tag "yolo")))) - (fails? (p.run s.local-tag + (p.run s.local_tag + (list (code.local_tag "yolo")))) + (fails? (p.run s.local_tag (list (code.tag ["yolo" "lol"])))))) ))) -(def: complex-values +(def: complex_values Test (`` ($_ _.and (~~ (template [<type> <parser> <ctor>] @@ -132,10 +132,10 @@ (def: #export test Test - (<| (_.context (name.module (name-of /._))) + (<| (_.context (name.module (name_of /._))) ($_ _.and - ..simple-values - ..complex-values + ..simple_values + ..complex_values ($_ _.and (_.test "Can parse any Code." (match [_ (#.Bit #1)] diff --git a/stdlib/source/test/lux/macro/syntax/common.lux b/stdlib/source/test/lux/macro/syntax/common.lux index 592baa036..769a28439 100644 --- a/stdlib/source/test/lux/macro/syntax/common.lux +++ b/stdlib/source/test/lux/macro/syntax/common.lux @@ -33,25 +33,25 @@ ["#." definition] ["#." export]]) -(def: annotations-equivalence +(def: annotations_equivalence (Equivalence /.Annotations) (list.equivalence (product.equivalence name.equivalence code.equivalence))) -(def: random-text +(def: random_text (Random Text) (random.ascii/alpha 10)) -(def: random-name +(def: random_name (Random Name) - (random.and ..random-text ..random-text)) + (random.and ..random_text ..random_text)) -(def: random-annotations +(def: random_annotations (Random /.Annotations) (do {! random.monad} [size (\ ! map (|>> (n.% 3)) random.nat)] - (random.list size (random.and random-name + (random.list size (random.and random_name ///code.random)))) (def: #export test @@ -63,33 +63,33 @@ (_.for [/.Annotations] ($_ _.and (do random.monad - [expected ..random-annotations] + [expected ..random_annotations] (_.cover [/reader.annotations /writer.annotations] (|> expected /writer.annotations list (<c>.run /reader.annotations) (case> (#try.Success actual) - (\ ..annotations-equivalence = expected actual) + (\ ..annotations_equivalence = expected actual) (#try.Failure error) false)))) - (_.cover [/.empty-annotations] - (|> /.empty-annotations + (_.cover [/.empty_annotations] + (|> /.empty_annotations /writer.annotations list (<c>.run /reader.annotations) (case> (#try.Success actual) - (\ ..annotations-equivalence = /.empty-annotations actual) + (\ ..annotations_equivalence = /.empty_annotations actual) (#try.Failure error) false))) )) (do {! random.monad} [size (\ ! map (|>> (n.% 3)) random.nat) - expected (random.list size ..random-text)] - (_.cover [/.Type-Var /reader.type-variables /writer.type-variables] + expected (random.list size ..random_text)] + (_.cover [/.Type_Var /reader.type_variables /writer.type_variables] (|> expected - /writer.type-variables - (<c>.run /reader.type-variables) + /writer.type_variables + (<c>.run /reader.type_variables) (case> (#try.Success actual) (\ (list.equivalence text.equivalence) = expected actual) @@ -98,8 +98,8 @@ (do {! random.monad} [size (\ ! map (|>> (n.% 3)) random.nat) expected (: (Random /.Declaration) - (random.and ..random-text - (random.list size ..random-text)))] + (random.and ..random_text + (random.list size ..random_text)))] (_.cover [/.Declaration /reader.declaration /writer.declaration] (|> expected /writer.declaration list @@ -112,13 +112,13 @@ (#try.Failure error) false)))) (do {! random.monad} - [expected (: (Random /.Typed-Input) + [expected (: (Random /.Typed_Input) (random.and ///code.random ///code.random))] - (_.cover [/.Typed-Input /reader.typed-input /writer.typed-input] + (_.cover [/.Typed_Input /reader.typed_input /writer.typed_input] (|> expected - /writer.typed-input list - (<c>.run /reader.typed-input) + /writer.typed_input list + (<c>.run /reader.typed_input) (case> (#try.Success actual) (let [equivalence (product.equivalence code.equivalence code.equivalence)] (\ equivalence = expected actual)) diff --git a/stdlib/source/test/lux/macro/syntax/common/definition.lux b/stdlib/source/test/lux/macro/syntax/common/definition.lux index 18af3edaa..937f5319a 100644 --- a/stdlib/source/test/lux/macro/syntax/common/definition.lux +++ b/stdlib/source/test/lux/macro/syntax/common/definition.lux @@ -25,7 +25,7 @@ ["#//" /// #_ ["#." code]]]) -(def: random-annotations +(def: random_annotations (Random Annotations) (let [name (random.and (random.ascii/alpha 5) (random.ascii/alpha 5))] @@ -37,7 +37,7 @@ (random.ascii/alpha 5) (random.or $//check.random $////code.random) - ..random-annotations + ..random_annotations random.bit )) @@ -47,15 +47,15 @@ #.mode #.Build} #.source [location.dummy 0 ""] #.location location.dummy - #.current-module #.None + #.current_module #.None #.modules (list) #.scopes (list) - #.type-context {#.ex-counter 0 - #.var-counter 0 - #.var-bindings (list)} + #.type_context {#.ex_counter 0 + #.var_counter 0 + #.var_bindings (list)} #.expected #.None #.seed 0 - #.scope-type-vars (list) + #.scope_type_vars (list) #.extensions [] #.host []}) @@ -71,7 +71,7 @@ [expected ..random type $////code.random - untyped-value $////code.random] + untyped_value $////code.random] ($_ _.and (_.cover [/.write /.parser] (case (<code>.run (/.parser compiler) @@ -82,7 +82,7 @@ (#try.Success actual) (\ /.equivalence = expected actual))) (_.cover [/.typed] - (let [expected (set@ #/.value (#.Left [type untyped-value]) expected)] + (let [expected (set@ #/.value (#.Left [type untyped_value]) expected)] (case (<code>.run (/.typed compiler) (list (/.write expected))) (#try.Failure error) @@ -90,12 +90,12 @@ (#try.Success actual) (\ /.equivalence = expected actual)))) - (_.cover [/.lacks-type!] - (let [expected (set@ #/.value (#.Right untyped-value) expected)] + (_.cover [/.lacks_type!] + (let [expected (set@ #/.value (#.Right untyped_value) expected)] (case (<code>.run (/.typed compiler) (list (/.write expected))) (#try.Failure error) - (exception.match? /.lacks-type! error) + (exception.match? /.lacks_type! error) (#try.Success actual) false))) diff --git a/stdlib/source/test/lux/macro/template.lux b/stdlib/source/test/lux/macro/template.lux index 8fa6a00ca..902e84255 100644 --- a/stdlib/source/test/lux/macro/template.lux +++ b/stdlib/source/test/lux/macro/template.lux @@ -20,9 +20,9 @@ [left random.nat mid random.nat right random.nat] - (with-expansions [<module> (as-is [-8.9 +6.7 .5 -4 +3 2 #1 #0 #c b "a"]) + (with_expansions [<module> (as_is [-8.9 +6.7 .5 -4 +3 2 #1 #0 #c b "a"]) <module>' "-8.9+6.7.5-4+32#1#0cba" - <short> (as-is ["a" b #c #0 #1 2 +3 -4 .5 +6.7 -8.9]) + <short> (as_is ["a" b #c #0 #1 2 +3 -4 .5 +6.7 -8.9]) <short>' "abc#0#12+3-4.5+6.7-8.9"] ($_ _.and (_.cover [/.splice] @@ -38,23 +38,23 @@ <short>' true _ false)) (_.cover [/.identifier] - (and (case (`` (name-of (~~ (/.identifier <short>)))) + (and (case (`` (name_of (~~ (/.identifier <short>)))) ["" <short>'] true _ false) - (case (`` (name-of (~~ (/.identifier <module> <short>)))) + (case (`` (name_of (~~ (/.identifier <module> <short>)))) [<module>' <short>'] true _ false) )) (_.cover [/.tag] - (and (case (`` (name-of (~~ (/.tag <short>)))) + (and (case (`` (name_of (~~ (/.tag <short>)))) ["" <short>'] true _ false) - (case (`` (name-of (~~ (/.tag <module> <short>)))) + (case (`` (name_of (~~ (/.tag <module> <short>)))) [<module>' <short>'] true _ false) )) - (_.cover [/.with-locals] - (/.with-locals [var0 var1] + (_.cover [/.with_locals] + (/.with_locals [var0 var1] (let [var0 left var1 right] (and (nat.= left var0) |