diff options
author | Eduardo Julian | 2017-11-21 16:09:07 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-21 16:09:07 -0400 |
commit | e37e3713e080606930a5f8442f03dabc4c26a7f9 (patch) | |
tree | ad772c1801af0d01dc105bccf85703f13b127e50 /stdlib/test | |
parent | 3eabc421e559e7e2f903e06eb6b47a2ee0cd25b9 (diff) |
- Fixed some bugs.
- Some small refactoring.
Diffstat (limited to '')
-rw-r--r-- | stdlib/test/test/lux.lux | 8 | ||||
-rw-r--r-- | stdlib/test/test/lux/data/coll/dict.lux | 2 | ||||
-rw-r--r-- | stdlib/test/test/lux/lang/syntax.lux | 61 |
3 files changed, 41 insertions, 30 deletions
diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux index 22190bd93..addc7a33a 100644 --- a/stdlib/test/test/lux.lux +++ b/stdlib/test/test/lux.lux @@ -136,10 +136,10 @@ (|> x' (/ y) (* y) (= x')))) ))))] - ["Nat" r;nat n.= n.+ n.- n.* n./ n.% n.> +0 +1 +1000000 %n (n.% +1000) id] - ["Int" r;int i.= i.+ i.- i.* i./ i.% i.> 0 1 1000000 %i (i.% 1000) id] - ["Frac" r;frac f.= f.+ f.- f.* f./ f.% f.> 0.0 1.0 1000000.0 %r id math;floor] - ["Deg" r;deg d.= d.+ d.- d.* d./ d.% d.> .0 ("lux deg max-value") ("lux deg max-value") %f id id] + ["Nat" r;nat n.= n.+ n.- n.* n./ n.% n.> +0 +1 +1000000 %n (n.% +1000) id] + ["Int" r;int i.= i.+ i.- i.* i./ i.% i.> 0 1 1000000 %i (i.% 1000) id] + ["Frac" r;frac f.= f.+ f.- f.* f./ f.% f.> 0.0 1.0 1000000.0 %r id math;floor] + ["Deg" r;deg d.= d.+ d.- d.* d./ d.% d.> .0 ("lux deg max") ("lux deg max") %f id id] ) (do-template [category rand-gen -> <- = <cap> %a %z] diff --git a/stdlib/test/test/lux/data/coll/dict.lux b/stdlib/test/test/lux/data/coll/dict.lux index 536ad8450..ddc1ddd2d 100644 --- a/stdlib/test/test/lux/data/coll/dict.lux +++ b/stdlib/test/test/lux/data/coll/dict.lux @@ -30,7 +30,7 @@ (not (&;empty? dict)))) (test "The functions 'entries', 'keys' and 'values' should be synchronized." - (:: (list;Eq<List> (eq;pair number;Eq<Nat> number;Eq<Nat>)) = + (:: (list;Eq<List> (eq;product number;Eq<Nat> number;Eq<Nat>)) = (&;entries dict) (list;zip2 (&;keys dict) (&;values dict)))) diff --git a/stdlib/test/test/lux/lang/syntax.lux b/stdlib/test/test/lux/lang/syntax.lux index 3eb9bfc02..4a7c16807 100644 --- a/stdlib/test/test/lux/lang/syntax.lux +++ b/stdlib/test/test/lux/lang/syntax.lux @@ -7,7 +7,8 @@ [text] (text format ["l" lexer]) - (coll [list])) + (coll [list] + [dict #+ Dict])) ["r" math/random "r/" Monad<Random>] (macro [code]) (lang ["&" syntax]) @@ -80,20 +81,23 @@ other code^] ($_ seq (test "Can parse Lux code." - (case (&;read "" [default-cursor +0 (code;to-text sample)]) + (case (&;read "" (dict;new text;Hash<Text>) + [default-cursor +0 (code;to-text sample)]) (#e;Error error) false (#e;Success [_ parsed]) (:: code;Eq<Code> = parsed sample))) (test "Can parse Lux multiple code nodes." - (case (&;read "" [default-cursor +0 (format (code;to-text sample) " " - (code;to-text other))]) + (case (&;read "" (dict;new text;Hash<Text>) + [default-cursor +0 (format (code;to-text sample) " " + (code;to-text other))]) (#e;Error error) false (#e;Success [remaining =sample]) - (case (&;read "" remaining) + (case (&;read "" (dict;new text;Hash<Text>) + remaining) (#e;Error error) false @@ -114,11 +118,12 @@ signed? r;bool #let [expected (|> numerator (f./ denominator) (f.* (if signed? -1.0 1.0)))]] (test "Can parse frac ratio syntax." - (case (&;read "" [default-cursor +0 - (format (if signed? "-" "") - (%i (frac-to-int numerator)) - "/" - (%i (frac-to-int denominator)))]) + (case (&;read "" (dict;new text;Hash<Text>) + [default-cursor +0 + (format (if signed? "-" "") + (%i (frac-to-int numerator)) + "/" + (%i (frac-to-int denominator)))]) (#e;Success [_ [_ (#;Frac actual)]]) (f.= expected actual) @@ -131,8 +136,9 @@ (do @ [expected (|> r;nat (:: @ map (n.% +1_000)))] (test "Can parse nat char syntax." - (case (&;read "" [default-cursor +0 - (format "#" (%t (text;from-code expected)) "")]) + (case (&;read "" (dict;new text;Hash<Text>) + [default-cursor +0 + (format "#" (%t (text;from-code expected)) "")]) (#e;Success [_ [_ (#;Nat actual)]]) (n.= expected actual) @@ -181,8 +187,9 @@ (let [bad-match (format (text;from-code x) "\n" (text;from-code y) "\n" (text;from-code z))] - (case (&;read "" [default-cursor +0 - (format "\"" bad-match "\"")]) + (case (&;read "" (dict;new text;Hash<Text>) + [default-cursor +0 + (format "\"" bad-match "\"")]) (#e;Error error) true @@ -195,9 +202,10 @@ good-output (format (text;from-code x) "\n" (text;from-code y) "\n" (text;from-code z))] - (case (&;read "" [(|> default-cursor (update@ #;column (n.+ (n.dec offset-size)))) - +0 - (format "\"" good-input "\"")]) + (case (&;read "" (dict;new text;Hash<Text>) + [(|> default-cursor (update@ #;column (n.+ (n.dec offset-size)))) + +0 + (format "\"" good-input "\"")]) (#e;Error error) false @@ -206,25 +214,28 @@ parsed (code;text good-output))))) (test "Can handle comments." - (case (&;read "" [default-cursor +0 - (format comment (code;to-text sample))]) + (case (&;read "" (dict;new text;Hash<Text>) + [default-cursor +0 + (format comment (code;to-text sample))]) (#e;Error error) false (#e;Success [_ parsed]) (:: code;Eq<Code> = parsed sample))) (test "Will reject unbalanced multi-line comments." - (and (case (&;read "" [default-cursor +0 - (format "#(" "#(" unbalanced-comment ")#" - (code;to-text sample))]) + (and (case (&;read "" (dict;new text;Hash<Text>) + [default-cursor +0 + (format "#(" "#(" unbalanced-comment ")#" + (code;to-text sample))]) (#e;Error error) true (#e;Success [_ parsed]) false) - (case (&;read "" [default-cursor +0 - (format "#(" unbalanced-comment ")#" ")#" - (code;to-text sample))]) + (case (&;read "" (dict;new text;Hash<Text>) + [default-cursor +0 + (format "#(" unbalanced-comment ")#" ")#" + (code;to-text sample))]) (#e;Error error) true |