aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2017-05-07 14:30:48 -0400
committerEduardo Julian2017-05-07 14:30:48 -0400
commitdb697bb636e2341d26bb188cc1b9981a1ab505d7 (patch)
treea1de1c7b0e48df4496e0e9183f485de7c341286c /stdlib/test
parent4744552df1f1285d600a13ed0a3cf8be2f336030 (diff)
- Changed the name of "let%" to "with-expansions".
Diffstat (limited to '')
-rw-r--r--stdlib/test/test/lux/control/effect.lux25
-rw-r--r--stdlib/test/test/lux/host.jvm.lux27
-rw-r--r--stdlib/test/test/lux/macro/ast.lux37
-rw-r--r--stdlib/test/test/lux/macro/syntax.lux76
-rw-r--r--stdlib/test/test/lux/type.lux40
5 files changed, 106 insertions, 99 deletions
diff --git a/stdlib/test/test/lux/control/effect.lux b/stdlib/test/test/lux/control/effect.lux
index 39e5afa5d..abbdca56a 100644
--- a/stdlib/test/test/lux/control/effect.lux
+++ b/stdlib/test/test/lux/control/effect.lux
@@ -46,19 +46,20 @@
## [Tests]
(test: "Algebraic effects"
- (let% [<single-effect-tests> (do-template [<op> <op-size> <field> <field-value>]
- [(io;run (with-handler Handler<EffABC,IO>
- (doE Functor<EffABC>
- []
- (lift (<op> <op-size> "YOLO")))))
- (n.= <field-value> (io;run (with-handler Handler<EffABC,IO>
- (doE Functor<EffABC>
- []
- (lift <field>)))))]
+ (with-expansions
+ [<single-effect-tests> (do-template [<op> <op-size> <field> <field-value>]
+ [(io;run (with-handler Handler<EffABC,IO>
+ (doE Functor<EffABC>
+ []
+ (lift (<op> <op-size> "YOLO")))))
+ (n.= <field-value> (io;run (with-handler Handler<EffABC,IO>
+ (doE Functor<EffABC>
+ []
+ (lift <field>)))))]
- [opA +10 fieldA +10]
- [opB +4 fieldB +20]
- [opC +2 fieldC +30])]
+ [opA +10 fieldA +10]
+ [opB +4 fieldB +20]
+ [opC +2 fieldC +30])]
(assert "Can handle effects using handlers."
(and <single-effect-tests>
diff --git a/stdlib/test/test/lux/host.jvm.lux b/stdlib/test/test/lux/host.jvm.lux
index 93fe5b5e6..ae12784af 100644
--- a/stdlib/test/test/lux/host.jvm.lux
+++ b/stdlib/test/test/lux/host.jvm.lux
@@ -54,19 +54,20 @@
(test: "Conversions"
[sample R;int]
- (let% [<int-convs> (do-template [<to> <from> <message>]
- [(assert <message>
- (or (|> sample <to> <from> (i.= sample))
- (let [capped-sample (|> sample <to> <from>)]
- (|> capped-sample <to> <from> (i.= capped-sample)))))]
-
- [&;l2b &;b2l "Can succesfully convert to/from byte."]
- [&;l2s &;s2l "Can succesfully convert to/from short."]
- [&;l2i &;i2l "Can succesfully convert to/from int."]
- [&;l2f &;f2l "Can succesfully convert to/from float."]
- [&;l2d &;d2l "Can succesfully convert to/from double."]
- [(<| &;i2c &;l2i) (<| &;i2l &;c2i) "Can succesfully convert to/from char."]
- )]
+ (with-expansions
+ [<int-convs> (do-template [<to> <from> <message>]
+ [(assert <message>
+ (or (|> sample <to> <from> (i.= sample))
+ (let [capped-sample (|> sample <to> <from>)]
+ (|> capped-sample <to> <from> (i.= capped-sample)))))]
+
+ [&;l2b &;b2l "Can succesfully convert to/from byte."]
+ [&;l2s &;s2l "Can succesfully convert to/from short."]
+ [&;l2i &;i2l "Can succesfully convert to/from int."]
+ [&;l2f &;f2l "Can succesfully convert to/from float."]
+ [&;l2d &;d2l "Can succesfully convert to/from double."]
+ [(<| &;i2c &;l2i) (<| &;i2l &;c2i) "Can succesfully convert to/from char."]
+ )]
($_ seq
<int-convs>
)))
diff --git a/stdlib/test/test/lux/macro/ast.lux b/stdlib/test/test/lux/macro/ast.lux
index 95ac999a0..8670ead71 100644
--- a/stdlib/test/test/lux/macro/ast.lux
+++ b/stdlib/test/test/lux/macro/ast.lux
@@ -10,23 +10,24 @@
lux/test)
(test: "AST"
- (let% [<tests> (do-template [<expr> <text>]
- [(assert (format "Can produce AST node: " <text>)
- (and (T/= <text> (&;to-text <expr>))
- (:: &;Eq<AST> = <expr> <expr>)))]
+ (with-expansions
+ [<tests> (do-template [<expr> <text>]
+ [(assert (format "Can produce AST node: " <text>)
+ (and (T/= <text> (&;to-text <expr>))
+ (:: &;Eq<AST> = <expr> <expr>)))]
- [(&;bool true) "true"]
- [(&;bool false) "false"]
- [(&;int 123) "123"]
- [(&;real 123.0) "123.0"]
- [(&;char #"\n") "#\"\\n\""]
- [(&;text "\n") "\"\\n\""]
- [(&;tag ["yolo" "lol"]) "#yolo;lol"]
- [(&;symbol ["yolo" "lol"]) "yolo;lol"]
- [(&;form (list (&;bool true) (&;int 123))) "(true 123)"]
- [(&;tuple (list (&;bool true) (&;int 123))) "[true 123]"]
- [(&;record (list [(&;bool true) (&;int 123)])) "{true 123}"]
- [(&;local-tag "lol") "#lol"]
- [(&;local-symbol "lol") "lol"]
- )]
+ [(&;bool true) "true"]
+ [(&;bool false) "false"]
+ [(&;int 123) "123"]
+ [(&;real 123.0) "123.0"]
+ [(&;char #"\n") "#\"\\n\""]
+ [(&;text "\n") "\"\\n\""]
+ [(&;tag ["yolo" "lol"]) "#yolo;lol"]
+ [(&;symbol ["yolo" "lol"]) "yolo;lol"]
+ [(&;form (list (&;bool true) (&;int 123))) "(true 123)"]
+ [(&;tuple (list (&;bool true) (&;int 123))) "[true 123]"]
+ [(&;record (list [(&;bool true) (&;int 123)])) "{true 123}"]
+ [(&;local-tag "lol") "#lol"]
+ [(&;local-symbol "lol") "lol"]
+ )]
($_ seq <tests>)))
diff --git a/stdlib/test/test/lux/macro/syntax.lux b/stdlib/test/test/lux/macro/syntax.lux
index f523f227c..41c372e15 100644
--- a/stdlib/test/test/lux/macro/syntax.lux
+++ b/stdlib/test/test/lux/macro/syntax.lux
@@ -63,22 +63,23 @@
## [Tests]
(test: "Simple value syntax."
- (let% [<simple-tests> (do-template [<assertion> <value> <ctor> <Eq> <get>]
- [(assert <assertion>
- (and (is? <Eq> <value> <get> (list (<ctor> <value>)))
- (found? (s;this? (<ctor> <value>)) (list (<ctor> <value>)))
- (enforced? (s;this! (<ctor> <value>)) (list (<ctor> <value>)))))]
-
- ["Can parse Bool syntax." true ast;bool bool;Eq<Bool> s;bool]
- ["Can parse Nat syntax." +123 ast;nat number;Eq<Nat> s;nat]
- ["Can parse Int syntax." 123 ast;int number;Eq<Int> s;int]
- ["Can parse Deg syntax." .123 ast;deg number;Eq<Deg> s;deg]
- ["Can parse Real syntax." 123.0 ast;real number;Eq<Real> s;real]
- ["Can parse Char syntax." #"\n" ast;char char;Eq<Char> s;char]
- ["Can parse Text syntax." "\n" ast;text text;Eq<Text> s;text]
- ["Can parse Symbol syntax." ["yolo" "lol"] ast;symbol ident;Eq<Ident> s;symbol]
- ["Can parse Tag syntax." ["yolo" "lol"] ast;tag ident;Eq<Ident> s;tag]
- )]
+ (with-expansions
+ [<simple-tests> (do-template [<assertion> <value> <ctor> <Eq> <get>]
+ [(assert <assertion>
+ (and (is? <Eq> <value> <get> (list (<ctor> <value>)))
+ (found? (s;this? (<ctor> <value>)) (list (<ctor> <value>)))
+ (enforced? (s;this! (<ctor> <value>)) (list (<ctor> <value>)))))]
+
+ ["Can parse Bool syntax." true ast;bool bool;Eq<Bool> s;bool]
+ ["Can parse Nat syntax." +123 ast;nat number;Eq<Nat> s;nat]
+ ["Can parse Int syntax." 123 ast;int number;Eq<Int> s;int]
+ ["Can parse Deg syntax." .123 ast;deg number;Eq<Deg> s;deg]
+ ["Can parse Real syntax." 123.0 ast;real number;Eq<Real> s;real]
+ ["Can parse Char syntax." #"\n" ast;char char;Eq<Char> s;char]
+ ["Can parse Text syntax." "\n" ast;text text;Eq<Text> s;text]
+ ["Can parse Symbol syntax." ["yolo" "lol"] ast;symbol ident;Eq<Ident> s;symbol]
+ ["Can parse Tag syntax." ["yolo" "lol"] ast;tag ident;Eq<Ident> s;tag]
+ )]
($_ seq
<simple-tests>
@@ -98,27 +99,28 @@
)))
(test: "Complex value syntax."
- (let% [<group-tests> (do-template [<type> <parser> <ctor>]
- [(assert (format "Can parse " <type> " syntax.")
- (and (match [true 123]
- (s;run (list (<ctor> (list (ast;bool true) (ast;int 123))))
- (<parser> (s;seq s;bool s;int))))
- (match true
- (s;run (list (<ctor> (list (ast;bool true))))
- (<parser> s;bool)))
- (fails? (s;run (list (<ctor> (list (ast;bool true) (ast;int 123))))
- (<parser> s;bool)))
- (match (#;Left true)
- (s;run (list (<ctor> (list (ast;bool true))))
- (<parser> (s;alt s;bool s;int))))
- (match (#;Right 123)
- (s;run (list (<ctor> (list (ast;int 123))))
- (<parser> (s;alt s;bool s;int))))
- (fails? (s;run (list (<ctor> (list (ast;real 123.0))))
- (<parser> (s;alt s;bool s;int))))))]
-
- ["form" s;form ast;form]
- ["tuple" s;tuple ast;tuple])]
+ (with-expansions
+ [<group-tests> (do-template [<type> <parser> <ctor>]
+ [(assert (format "Can parse " <type> " syntax.")
+ (and (match [true 123]
+ (s;run (list (<ctor> (list (ast;bool true) (ast;int 123))))
+ (<parser> (s;seq s;bool s;int))))
+ (match true
+ (s;run (list (<ctor> (list (ast;bool true))))
+ (<parser> s;bool)))
+ (fails? (s;run (list (<ctor> (list (ast;bool true) (ast;int 123))))
+ (<parser> s;bool)))
+ (match (#;Left true)
+ (s;run (list (<ctor> (list (ast;bool true))))
+ (<parser> (s;alt s;bool s;int))))
+ (match (#;Right 123)
+ (s;run (list (<ctor> (list (ast;int 123))))
+ (<parser> (s;alt s;bool s;int))))
+ (fails? (s;run (list (<ctor> (list (ast;real 123.0))))
+ (<parser> (s;alt s;bool s;int))))))]
+
+ ["form" s;form ast;form]
+ ["tuple" s;tuple ast;tuple])]
($_ seq
<group-tests>
diff --git a/stdlib/test/test/lux/type.lux b/stdlib/test/test/lux/type.lux
index 77858e7fa..e0087960f 100644
--- a/stdlib/test/test/lux/type.lux
+++ b/stdlib/test/test/lux/type.lux
@@ -92,16 +92,17 @@
(seqM @))
#let [(^open "&/") &;Eq<Type>
(^open "L/") (list;Eq<List> &;Eq<Type>)]]
- (let% [<struct-tests> (do-template [<desc> <ctor> <dtor> <unit>]
- [(assert (format "Can build and tear-down " <desc> " types.")
- (let [flat (|> members <ctor> <dtor>)]
- (or (L/= members flat)
- (and (L/= (list) members)
- (L/= (list <unit>) flat)))))]
-
- ["variant" &;variant &;flatten-variant Void]
- ["tuple" &;tuple &;flatten-tuple Unit]
- )]
+ (with-expansions
+ [<struct-tests> (do-template [<desc> <ctor> <dtor> <unit>]
+ [(assert (format "Can build and tear-down " <desc> " types.")
+ (let [flat (|> members <ctor> <dtor>)]
+ (or (L/= members flat)
+ (and (L/= (list) members)
+ (L/= (list <unit>) flat)))))]
+
+ ["variant" &;variant &;flatten-variant Void]
+ ["tuple" &;tuple &;flatten-tuple Unit]
+ )]
($_ seq
<struct-tests>
)))
@@ -141,15 +142,16 @@
_
true))))
#let [(^open "&/") &;Eq<Type>]]
- (let% [<quant-tests> (do-template [<desc> <ctor> <dtor>]
- [(assert (format "Can build and tear-down " <desc> " types.")
- (let [[flat-size flat-body] (|> extra (<ctor> size) <dtor>)]
- (and (n.= size flat-size)
- (&/= extra flat-body))))]
-
- ["universally-quantified" &;univq &;flatten-univq]
- ["existentially-quantified" &;exq &;flatten-exq]
- )]
+ (with-expansions
+ [<quant-tests> (do-template [<desc> <ctor> <dtor>]
+ [(assert (format "Can build and tear-down " <desc> " types.")
+ (let [[flat-size flat-body] (|> extra (<ctor> size) <dtor>)]
+ (and (n.= size flat-size)
+ (&/= extra flat-body))))]
+
+ ["universally-quantified" &;univq &;flatten-univq]
+ ["existentially-quantified" &;exq &;flatten-exq]
+ )]
($_ seq
<quant-tests>
)))