diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/control/parser.lux | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index a8c91fbaf..9acf45684 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -16,10 +16,10 @@ [data [number ["n" nat]] - ["." text ("#@." equivalence) + ["." text ("#\." equivalence) ["%" format (#+ format)]] [collection - ["." list ("#@." functor)]]] + ["." list ("#\." functor)]]] [math ["." random]] [macro @@ -32,7 +32,7 @@ (All [a] (-> Text (Try a) Bit)) (case input (#try.Failure actual) - (text@= expected actual) + (text\= expected actual) _ #0)) @@ -92,16 +92,16 @@ (match #.None #1)))) (_.cover [/.some] - (and (|> (list@map code.nat expected+) + (and (|> (list\map code.nat expected+) (/.run (/.some s.nat)) (match actual (:: (list.equivalence n.equivalence) = expected+ actual))) - (|> (list@map (|>> .int code.int) expected+) + (|> (list\map (|>> .int code.int) expected+) (/.run (/.some s.nat)) (match #.Nil #1)))) (_.cover [/.many] - (and (|> (list@map code.nat expected+) + (and (|> (list\map code.nat expected+) (/.run (/.many s.nat)) (match actual (:: (list.equivalence n.equivalence) = expected+ actual))) @@ -109,7 +109,7 @@ (/.run (/.many s.nat)) (match (list actual) (n.= expected0 actual))) - (|> (list@map (|>> .int code.int) expected+) + (|> (list\map (|>> .int code.int) expected+) (/.run (/.many s.nat)) fails?))) (_.cover [/.filter] @@ -174,64 +174,64 @@ separator (random.ascii 1)] ($_ _.and (_.cover [/.exactly] - (and (|> (list@map code.nat expected+) + (and (|> (list\map code.nat expected+) (/.run (/.exactly times s.nat)) (match actual (:: (list.equivalence n.equivalence) = (list.take times expected+) actual))) - (|> (list@map code.nat expected+) + (|> (list\map code.nat expected+) (/.run (/.exactly (inc variadic) s.nat)) fails?))) (_.cover [/.at-least] - (and (|> (list@map code.nat expected+) + (and (|> (list\map code.nat expected+) (/.run (/.at-least times s.nat)) (match actual (:: (list.equivalence n.equivalence) = expected+ actual))) - (|> (list@map code.nat expected+) + (|> (list\map code.nat expected+) (/.run (/.at-least (inc variadic) s.nat)) fails?))) (_.cover [/.at-most] - (and (|> (list@map code.nat expected+) + (and (|> (list\map code.nat expected+) (/.run (/.at-most times s.nat)) (match actual (:: (list.equivalence n.equivalence) = (list.take times expected+) actual))) - (|> (list@map code.nat expected+) + (|> (list\map code.nat expected+) (/.run (/.at-most (inc variadic) s.nat)) (match actual (:: (list.equivalence n.equivalence) = expected+ actual))))) (_.cover [/.between] - (and (|> (list@map code.nat expected+) + (and (|> (list\map code.nat expected+) (/.run (/.between times variadic s.nat)) (match actual (:: (list.equivalence n.equivalence) = expected+ actual))) - (|> (list@map code.nat (list.take times expected+)) + (|> (list\map code.nat (list.take times expected+)) (/.run (/.between times variadic s.nat)) (match actual (:: (list.equivalence n.equivalence) = (list.take times expected+) actual))))) (_.cover [/.sep-by] - (|> (list.interpose (code.text separator) (list@map code.nat expected+)) + (|> (list.interpose (code.text separator) (list\map code.nat expected+)) (/.run (/.sep-by (s.this! (code.text separator)) s.nat)) (match actual (:: (list.equivalence n.equivalence) = expected+ actual)))) (_.cover [/.remaining] - (|> (list@map code.nat expected+) + (|> (list\map code.nat expected+) (/.run /.remaining) (match actual (:: (list.equivalence code.equivalence) = - (list@map code.nat expected+) + (list\map code.nat expected+) actual)))) (_.cover [/.default] (and (|> (/.run (/.default wrong (:: /.monad wrap expected)) (list)) @@ -298,14 +298,19 @@ (list (code.nat odd))) fails?))) (_.cover [/.speculative] - (and (|> (/.run (/.and (/.speculative even^) nat^) - (list (code.nat even))) - (match [speculation actual] - (and (n.= speculation actual) - (n.= expected actual)))) - (|> (/.run (/.and (/.speculative even^) nat^) - (list (code.nat odd))) - fails?))) + (let [happy-path! + (|> (/.run (/.and (/.speculative even^) nat^) + (list (code.nat even))) + (match [speculation actual] + (and (n.= speculation actual) + (n.= even actual)))) + + sad-path! + (|> (/.run (/.and (/.speculative even^) nat^) + (list (code.nat odd))) + fails?)] + (and happy-path! + sad-path!))) (_.cover [/.codec] (|> (/.run (/.codec n.decimal s.text) (list (code.text (%.nat expected)))) |