aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/test/test/luxc/parser.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--new-luxc/test/test/luxc/parser.lux110
1 files changed, 56 insertions, 54 deletions
diff --git a/new-luxc/test/test/luxc/parser.lux b/new-luxc/test/test/luxc/parser.lux
index 33b6eba36..21d34f7c0 100644
--- a/new-luxc/test/test/luxc/parser.lux
+++ b/new-luxc/test/test/luxc/parser.lux
@@ -75,16 +75,17 @@
(r;either simple^
composite^))))))
-(test: "Lux code parser."
+(context: "Lux code parser."
+ #seed +15765541630132670628
[sample code^]
- (assert "Can parse Lux code."
- (case (&;parse [default-cursor (code;to-text sample)])
- (#R;Error error)
- false
+ (test "Can parse Lux code."
+ (case (&;parse [default-cursor (code;to-text sample)])
+ (#R;Error error)
+ false
- (#R;Success [_ parsed])
- (:: code;Eq<Code> = parsed sample))
- ))
+ (#R;Success [_ parsed])
+ (:: code;Eq<Code> = parsed sample))
+ ))
(def: comment-text^
(r;Random Text)
@@ -109,7 +110,8 @@
nested^)]
(wrap (format "#( " comment " )#")))))))
-(test: "Multi-line text & comments."
+(context: "Multi-line text & comments."
+ #seed +13835085537605735783
[#let [char-gen (|> r;char (r;filter (function [value]
(not (or (char;space? value)
(C/= #"\"" value)
@@ -123,57 +125,57 @@
comment comment^
unbalanced-comment comment-text^]
($_ seq
- (assert "Will reject invalid multi-line text."
- (let [bad-match (format (char;as-text x) "\n"
+ (test "Will reject invalid multi-line text."
+ (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 "\"")])
+ (#R;Error error)
+ true
+
+ (#R;Success [_ parsed])
+ false)))
+ (test "Will accept valid multi-line text"
+ (let [good-input (format (char;as-text x) "\n"
+ offset (char;as-text y) "\n"
+ offset (char;as-text z))
+ good-output (format (char;as-text x) "\n"
(char;as-text y) "\n"
(char;as-text z))]
- (case (&;parse [default-cursor
- (format "\"" bad-match "\"")])
- (#R;Error error)
- true
-
- (#R;Success [_ parsed])
- false)))
- (assert "Will accept valid multi-line text"
- (let [good-input (format (char;as-text x) "\n"
- offset (char;as-text y) "\n"
- offset (char;as-text z))
- 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 "\"")])
- (#R;Error error)
- false
-
- (#R;Success [_ parsed])
- (:: code;Eq<Code> =
- parsed
- (code;text good-output)))))
- (assert "Can handle comments."
- (case (&;parse [default-cursor
- (format comment (code;to-text sample))])
+ (case (&;parse [(|> default-cursor
+ (update@ #;column (n.+ (n.dec offset-size))))
+ (format "\"" good-input "\"")])
(#R;Error error)
false
(#R;Success [_ parsed])
- (:: code;Eq<Code> = parsed sample)))
- (assert "Will reject unbalanced multi-line comments."
- (and (case (&;parse [default-cursor
- (format "#(" "#(" unbalanced-comment ")#"
- (code;to-text sample))])
- (#R;Error error)
- true
+ (:: code;Eq<Code> =
+ parsed
+ (code;text good-output)))))
+ (test "Can handle comments."
+ (case (&;parse [default-cursor
+ (format comment (code;to-text sample))])
+ (#R;Error error)
+ false
+
+ (#R;Success [_ parsed])
+ (:: code;Eq<Code> = parsed sample)))
+ (test "Will reject unbalanced multi-line comments."
+ (and (case (&;parse [default-cursor
+ (format "#(" "#(" unbalanced-comment ")#"
+ (code;to-text sample))])
+ (#R;Error error)
+ true
- (#R;Success [_ parsed])
- false)
- (case (&;parse [default-cursor
- (format "#(" unbalanced-comment ")#" ")#"
- (code;to-text sample))])
- (#R;Error error)
- true
+ (#R;Success [_ parsed])
+ false)
+ (case (&;parse [default-cursor
+ (format "#(" unbalanced-comment ")#" ")#"
+ (code;to-text sample))])
+ (#R;Error error)
+ true
- (#R;Success [_ parsed])
- false)))
+ (#R;Success [_ parsed])
+ false)))
))