aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/test
diff options
context:
space:
mode:
Diffstat (limited to 'new-luxc/test')
-rw-r--r--new-luxc/test/test/luxc/parser.lux53
1 files changed, 27 insertions, 26 deletions
diff --git a/new-luxc/test/test/luxc/parser.lux b/new-luxc/test/test/luxc/parser.lux
index 3e363af78..9259c1101 100644
--- a/new-luxc/test/test/luxc/parser.lux
+++ b/new-luxc/test/test/luxc/parser.lux
@@ -7,6 +7,7 @@
(text format
["l" lexer])
[number]
+ ["E" error]
(coll [list]))
["R" math/random "R/" Monad<Random>]
(macro [ast])
@@ -77,11 +78,11 @@
(test: "Lux code parser."
[sample ast^]
(assert "Can parse Lux code."
- (case (&;parse default-cursor (ast;to-text sample))
- (#;Left error)
+ (case (&;parse [default-cursor (ast;to-text sample)])
+ (#E;Error error)
false
- (#;Right [remaining-code parsed _])
+ (#E;Success [_ parsed])
(:: ast;Eq<AST> = parsed sample))
))
@@ -126,12 +127,12 @@
(let [bad-match (format (char;as-text x) "\n"
(char;as-text y) "\n"
(char;as-text z))]
- (case (&;parse default-cursor
- (format "\"" bad-match "\""))
- (#;Left error)
+ (case (&;parse [default-cursor
+ (format "\"" bad-match "\"")])
+ (#E;Error error)
true
- (#;Right [remaining-code parsed _])
+ (#E;Success [_ parsed])
false)))
(assert "Will accept valid multi-line text"
(let [good-input (format (char;as-text x) "\n"
@@ -140,39 +141,39 @@
good-output (format (char;as-text x) "\n"
(char;as-text y) "\n"
(char;as-text z))]
- (case (&;parse (|> default-cursor
- (update@ #;column (n.+ (n.dec offset-size))))
- (format "\"" good-input "\""))
- (#;Left error)
+ (case (&;parse [(|> default-cursor
+ (update@ #;column (n.+ (n.dec offset-size))))
+ (format "\"" good-input "\"")])
+ (#E;Error error)
false
- (#;Right [remaining-code parsed _])
+ (#E;Success [_ parsed])
(:: ast;Eq<AST> =
parsed
(ast;text good-output)))))
(assert "Can handle comments."
- (case (&;parse default-cursor
- (format comment (ast;to-text sample)))
- (#;Left error)
+ (case (&;parse [default-cursor
+ (format comment (ast;to-text sample))])
+ (#E;Error error)
false
- (#;Right [remaining-code parsed _])
+ (#E;Success [_ parsed])
(:: ast;Eq<AST> = parsed sample)))
(assert "Will reject unbalanced multi-line comments."
- (and (case (&;parse default-cursor
- (format "#(" "#(" unbalanced-comment ")#"
- (ast;to-text sample)))
- (#;Left error)
+ (and (case (&;parse [default-cursor
+ (format "#(" "#(" unbalanced-comment ")#"
+ (ast;to-text sample))])
+ (#E;Error error)
true
- (#;Right [remaining-code parsed _])
+ (#E;Success [_ parsed])
false)
- (case (&;parse default-cursor
- (format "#(" unbalanced-comment ")#" ")#"
- (ast;to-text sample)))
- (#;Left error)
+ (case (&;parse [default-cursor
+ (format "#(" unbalanced-comment ")#" ")#"
+ (ast;to-text sample))])
+ (#E;Error error)
true
- (#;Right [remaining-code parsed _])
+ (#E;Success [_ parsed])
false)))
))