diff options
Diffstat (limited to '')
-rw-r--r-- | new-luxc/test/test/luxc/parser.lux | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/new-luxc/test/test/luxc/parser.lux b/new-luxc/test/test/luxc/parser.lux index 21d34f7c0..b7eaa0ea5 100644 --- a/new-luxc/test/test/luxc/parser.lux +++ b/new-luxc/test/test/luxc/parser.lux @@ -2,8 +2,7 @@ lux (lux [io] (control monad) - (data [char "C/" Eq<Char>] - [text "T/" Eq<Text>] + (data [text "T/" Eq<Text>] (text format ["l" lexer]) [number] @@ -27,9 +26,9 @@ delimiters "()[]{}#;" space "\t\v \n\r\f" invalid-range (format digits delimiters space) - char-gen (|> r;char + char-gen (|> r;nat (r;filter (function [sample] - (not (text;contains? (char;as-text sample) + (not (text;contains? (text;from-code sample) invalid-range)))))] size (|> r;nat (:: @ map (|>. (n.% +20) (n.max +1))))] (r;text' char-gen size))) @@ -49,7 +48,6 @@ (|> r;real (r/map (|>. #;Real [default-cursor]))))) textual^ (: (r;Random Code) ($_ r;either - (|> r;char (r/map (|>. #;Char [default-cursor]))) (do r;Monad<Random> [size (|> r;nat (r/map (n.% +20)))] (|> (r;text size) (r/map (|>. #;Text [default-cursor])))) @@ -89,12 +87,11 @@ (def: comment-text^ (r;Random Text) - (let [char-gen (|> r;char (r;filter (function [value] - (not (or (char;space? value) - (C/= #"\n" value) - (C/= #"#" value) - (C/= #"(" value) - (C/= #")" value))))))] + (let [char-gen (|> r;nat (r;filter (function [value] + (not (or (text;space? value) + (n.= (char "#") value) + (n.= (char "(") value) + (n.= (char ")") value))))))] (do r;Monad<Random> [size (|> r;nat (r/map (n.% +20)))] (r;text' char-gen size)))) @@ -112,10 +109,9 @@ (context: "Multi-line text & comments." #seed +13835085537605735783 - [#let [char-gen (|> r;char (r;filter (function [value] - (not (or (char;space? value) - (C/= #"\"" value) - (C/= #"\n" value))))))] + [#let [char-gen (|> r;nat (r;filter (function [value] + (not (or (text;space? value) + (n.= (char "\"") value))))))] x char-gen y char-gen z char-gen @@ -126,9 +122,9 @@ unbalanced-comment comment-text^] ($_ seq (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))] + (let [bad-match (format (text;from-code x) "\n" + (text;from-code y) "\n" + (text;from-code z))] (case (&;parse [default-cursor (format "\"" bad-match "\"")]) (#R;Error error) @@ -137,12 +133,12 @@ (#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))] + (let [good-input (format (text;from-code x) "\n" + offset (text;from-code y) "\n" + offset (text;from-code z)) + good-output (format (text;from-code x) "\n" + (text;from-code y) "\n" + (text;from-code z))] (case (&;parse [(|> default-cursor (update@ #;column (n.+ (n.dec offset-size)))) (format "\"" good-input "\"")]) |