diff options
Diffstat (limited to 'stdlib/source/test/lux/control/parser/text.lux')
-rw-r--r-- | stdlib/source/test/lux/control/parser/text.lux | 168 |
1 files changed, 84 insertions, 84 deletions
diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux index 1686bb27c..ae2c448c7 100644 --- a/stdlib/source/test/lux/control/parser/text.lux +++ b/stdlib/source/test/lux/control/parser/text.lux @@ -38,8 +38,8 @@ (<| (_.context (name.module (name-of /._))) ($_ _.and (_.test "Can detect the end of the input." - (|> (/.run "" - /.end) + (|> (/.run /.end + "") (case> (#.Right _) true _ false))) (do r.monad [size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10)))) @@ -48,126 +48,126 @@ (r.filter (|>> (text@= sample) not)))] ($_ _.and (_.test "Won't mistake non-empty text for no more input." - (|> (/.run sample - /.end) + (|> (/.run /.end + sample) (case> (#.Left _) true _ false))) (_.test "Can find literal text fragments." - (and (|> (/.run sample - (/.this sample)) + (and (|> (/.run (/.this sample) + sample) (case> (#.Right []) true _ false)) - (|> (/.run non-sample - (/.this sample)) + (|> (/.run (/.this sample) + non-sample) (case> (#.Left _) true _ false)))) )) ($_ _.and (_.test "Can lex anything" - (and (should-pass "A" (/.run "A" - /.any)) - (should-fail (/.run "" - /.any)))) + (and (should-pass "A" (/.run /.any + "A")) + (should-fail (/.run /.any + "")))) (_.test "Can lex characters ranges." - (and (should-pass "Y" (/.run "Y" - (/.range (char "X") (char "Z")))) - (should-fail (/.run "M" - (/.range (char "X") (char "Z")))))) + (and (should-pass "Y" (/.run (/.range (char "X") (char "Z")) + "Y")) + (should-fail (/.run (/.range (char "X") (char "Z")) + "M")))) (_.test "Can lex upper-case and lower-case letters." - (and (should-pass "Y" (/.run "Y" - /.upper)) - (should-fail (/.run "m" - /.upper)) + (and (should-pass "Y" (/.run /.upper + "Y")) + (should-fail (/.run /.upper + "m")) - (should-pass "y" (/.run "y" - /.lower)) - (should-fail (/.run "M" - /.lower)))) + (should-pass "y" (/.run /.lower + "y")) + (should-fail (/.run /.lower + "M")))) (_.test "Can lex numbers." - (and (should-pass "1" (/.run "1" - /.decimal)) - (should-fail (/.run " " - /.decimal)) + (and (should-pass "1" (/.run /.decimal + "1")) + (should-fail (/.run /.decimal + " ")) - (should-pass "7" (/.run "7" - /.octal)) - (should-fail (/.run "8" - /.octal)) + (should-pass "7" (/.run /.octal + "7")) + (should-fail (/.run /.octal + "8")) - (should-pass "1" (/.run "1" - /.hexadecimal)) - (should-pass "a" (/.run "a" - /.hexadecimal)) - (should-pass "A" (/.run "A" - /.hexadecimal)) - (should-fail (/.run " " - /.hexadecimal)) + (should-pass "1" (/.run /.hexadecimal + "1")) + (should-pass "a" (/.run /.hexadecimal + "a")) + (should-pass "A" (/.run /.hexadecimal + "A")) + (should-fail (/.run /.hexadecimal + " ")) )) (_.test "Can lex alphabetic characters." - (and (should-pass "A" (/.run "A" - /.alpha)) - (should-pass "a" (/.run "a" - /.alpha)) - (should-fail (/.run "1" - /.alpha)))) + (and (should-pass "A" (/.run /.alpha + "A")) + (should-pass "a" (/.run /.alpha + "a")) + (should-fail (/.run /.alpha + "1")))) (_.test "Can lex alphanumeric characters." - (and (should-pass "A" (/.run "A" - /.alpha-num)) - (should-pass "a" (/.run "a" - /.alpha-num)) - (should-pass "1" (/.run "1" - /.alpha-num)) - (should-fail (/.run " " - /.alpha-num)))) + (and (should-pass "A" (/.run /.alpha-num + "A")) + (should-pass "a" (/.run /.alpha-num + "a")) + (should-pass "1" (/.run /.alpha-num + "1")) + (should-fail (/.run /.alpha-num + " ")))) (_.test "Can lex white-space." - (and (should-pass " " (/.run " " - /.space)) - (should-fail (/.run "8" - /.space)))) + (and (should-pass " " (/.run /.space + " ")) + (should-fail (/.run /.space + "8")))) ) ($_ _.and (_.test "Can combine lexers sequentially." - (and (|> (/.run "YO" - (p.and /.any /.any)) + (and (|> (/.run (p.and /.any /.any) + "YO") (case> (#.Right ["Y" "O"]) true _ false)) - (should-fail (/.run "Y" - (p.and /.any /.any))))) + (should-fail (/.run (p.and /.any /.any) + "Y")))) (_.test "Can create the opposite of a lexer." - (and (should-pass "a" (/.run "a" - (/.not (p.or /.decimal /.upper)))) - (should-fail (/.run "A" - (/.not (p.or /.decimal /.upper)))))) + (and (should-pass "a" (/.run (/.not (p.or /.decimal /.upper)) + "a")) + (should-fail (/.run (/.not (p.or /.decimal /.upper)) + "A")))) (_.test "Can select from among a set of characters." - (and (should-pass "C" (/.run "C" - (/.one-of "ABC"))) - (should-fail (/.run "D" - (/.one-of "ABC"))))) + (and (should-pass "C" (/.run (/.one-of "ABC") + "C")) + (should-fail (/.run (/.one-of "ABC") + "D")))) (_.test "Can avoid a set of characters." - (and (should-pass "D" (/.run "D" - (/.none-of "ABC"))) - (should-fail (/.run "C" - (/.none-of "ABC"))))) + (and (should-pass "D" (/.run (/.none-of "ABC") + "D")) + (should-fail (/.run (/.none-of "ABC") + "C")))) (_.test "Can lex using arbitrary predicates." - (and (should-pass "D" (/.run "D" - (/.satisfies (function (_ c) true)))) - (should-fail (/.run "C" - (/.satisfies (function (_ c) false)))))) + (and (should-pass "D" (/.run (/.satisfies (function (_ c) true)) + "D")) + (should-fail (/.run (/.satisfies (function (_ c) false)) + "C")))) (_.test "Can apply a lexer multiple times." - (and (should-pass "0123456789ABCDEF" (/.run "0123456789ABCDEF" - (/.many /.hexadecimal))) - (should-fail (/.run "yolo" - (/.many /.hexadecimal))) + (and (should-pass "0123456789ABCDEF" (/.run (/.many /.hexadecimal) + "0123456789ABCDEF")) + (should-fail (/.run (/.many /.hexadecimal) + "yolo")) - (should-pass "" (/.run "" - (/.some /.hexadecimal))))) + (should-pass "" (/.run (/.some /.hexadecimal) + "")))) ) ))) |