diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux/control/parser.lux | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index fc8de4828..58a35ae02 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -15,7 +15,7 @@ ["s" code]]] [data [number - ["." nat]] + ["n" nat]] ["." text ("#;." equivalence) ["%" format (#+ format)]] [collection @@ -76,17 +76,17 @@ Test (do r.monad [expected0 r.nat - variadic (:: @ map (|>> (n/max 1) (n/min 20)) r.nat) + variadic (:: @ map (|>> (n.max 1) (n.min 20)) r.nat) expected+ (r.list variadic r.nat) - even0 (r.filter n/even? r.nat) - odd0 (r.filter n/odd? r.nat) + even0 (r.filter n.even? r.nat) + odd0 (r.filter n.odd? r.nat) not0 r.bit] ($_ _.and (_.test "Can optionally succeed with some parser." (and (|> (list (code.nat expected0)) (/.run (/.maybe s.nat)) (match (#.Some actual) - (n/= expected0 actual))) + (n.= expected0 actual))) (|> (list (code.int (.int expected0))) (/.run (/.maybe s.nat)) (match #.None @@ -95,7 +95,7 @@ (and (|> (list;map code.nat expected+) (/.run (/.some s.nat)) (match actual - (:: (list.equivalence nat.equivalence) = expected+ actual))) + (:: (list.equivalence n.equivalence) = expected+ actual))) (|> (list;map (|>> .int code.int) expected+) (/.run (/.some s.nat)) (match #.Nil @@ -104,23 +104,23 @@ (and (|> (list;map code.nat expected+) (/.run (/.many s.nat)) (match actual - (:: (list.equivalence nat.equivalence) = expected+ actual))) + (:: (list.equivalence n.equivalence) = expected+ actual))) (|> (list (code.nat expected0)) (/.run (/.many s.nat)) (match (list actual) - (n/= expected0 actual))) + (n.= expected0 actual))) (|> (list;map (|>> .int code.int) expected+) (/.run (/.many s.nat)) fails?))) (_.test "Can use either parser." - (let [even (/.filter n/even? s.nat) - odd (/.filter n/odd? s.nat)] + (let [even (/.filter n.even? s.nat) + odd (/.filter n.odd? s.nat)] (and (|> (list (code.nat even0)) (/.run (/.either even odd)) - (match actual (n/= even0 actual))) + (match actual (n.= even0 actual))) (|> (list (code.nat odd0)) (/.run (/.either even odd)) - (match actual (n/= odd0 actual))) + (match actual (n.= odd0 actual))) (|> (list (code.bit not0)) (/.run (/.either even odd)) fails?)))) @@ -137,8 +137,8 @@ Test (do r.monad [failure (r.ascii 1) - variadic (:: @ map (|>> (n/max 1) (n/min 20)) r.nat) - times (:: @ map (n/% variadic) r.nat) + variadic (:: @ map (|>> (n.max 1) (n.min 20)) r.nat) + times (:: @ map (n.% variadic) r.nat) expected+ (r.list variadic r.nat) separator (r.ascii 1)] ($_ _.and @@ -150,7 +150,7 @@ (and (|> (list;map code.nat expected+) (/.run (/.exactly times s.nat)) (match actual - (:: (list.equivalence nat.equivalence) = + (:: (list.equivalence n.equivalence) = (list.take times expected+) actual))) (|> (list;map code.nat expected+) @@ -160,7 +160,7 @@ (and (|> (list;map code.nat expected+) (/.run (/.at-least times s.nat)) (match actual - (:: (list.equivalence nat.equivalence) = + (:: (list.equivalence n.equivalence) = expected+ actual))) (|> (list;map code.nat expected+) @@ -170,33 +170,33 @@ (and (|> (list;map code.nat expected+) (/.run (/.at-most times s.nat)) (match actual - (:: (list.equivalence nat.equivalence) = + (:: (list.equivalence n.equivalence) = (list.take times expected+) actual))) (|> (list;map code.nat expected+) (/.run (/.at-most (inc variadic) s.nat)) (match actual - (:: (list.equivalence nat.equivalence) = + (:: (list.equivalence n.equivalence) = expected+ actual))))) (_.test "Can apply a parser between N and M times." (and (|> (list;map code.nat expected+) (/.run (/.between times variadic s.nat)) (match actual - (:: (list.equivalence nat.equivalence) = + (:: (list.equivalence n.equivalence) = expected+ actual))) (|> (list;map code.nat (list.take times expected+)) (/.run (/.between times variadic s.nat)) (match actual - (:: (list.equivalence nat.equivalence) = + (:: (list.equivalence n.equivalence) = (list.take times expected+) actual))))) (_.test "Can parse while taking separators into account." (|> (list.interpose (code.text separator) (list;map code.nat expected+)) (/.run (/.sep-by (s.this! (code.text separator)) s.nat)) (match actual - (:: (list.equivalence nat.equivalence) = + (:: (list.equivalence n.equivalence) = expected+ actual)))) (_.test "Can obtain the whole of the remaining input." |