diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/control/parser/synthesis.lux | 113 |
1 files changed, 57 insertions, 56 deletions
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 |