aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/test.lux
diff options
context:
space:
mode:
authorEduardo Julian2017-12-02 12:49:25 -0400
committerEduardo Julian2017-12-02 12:49:25 -0400
commit1651d847ba70ee36171f3809a25bece325fd5715 (patch)
tree9cf19984d86d9adb336859b396ba3199c8d28890 /stdlib/source/lux/test.lux
parent46955edbe6cea9f367562b9fb17cef526109d9e0 (diff)
- Added context-sensitive macro-expansion by means of "lux in-module", and removed all the (now unnecessary) #hidden tags.
- Fixed a bug when loading the imports from the cache. - Added special notation for context-sensitive macro-expansion.
Diffstat (limited to 'stdlib/source/lux/test.lux')
-rw-r--r--stdlib/source/lux/test.lux44
1 files changed, 19 insertions, 25 deletions
diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux
index 7c24e22d5..57d5ae2f3 100644
--- a/stdlib/source/lux/test.lux
+++ b/stdlib/source/lux/test.lux
@@ -19,7 +19,7 @@
## [Host]
(do-template [<name> <signal>]
- [(def: #hidden <name> (IO Bottom)
+ [(def: <name> (IO Bottom)
(io ("lux io exit" <signal>)))]
[exit 0]
@@ -39,8 +39,6 @@
(def: pcg-32-magic-inc Nat +12345)
## [Values]
-(def: #hidden Monad<Random> (Monad r.Random) r.Monad<Random>)
-
(def: success Counters [+1 +0])
(def: failure Counters [+0 +1])
(def: start Counters [+0 +0])
@@ -67,7 +65,7 @@
(-> Text Bool Test)
(:: r.Monad<Random> wrap (assert message condition)))
-(def: #hidden (run' tests)
+(def: (run' tests)
(-> (List [Text (IO Test) Text]) (Promise Counters))
(do Monad<Promise>
[test-runs (|> tests
@@ -120,8 +118,6 @@
(product.right (r.run prng' (times (n/dec amount) test)))))])))))
## [Syntax]
-(def: #hidden _code/text_ code.text)
-
(syntax: #export (context: description test)
{#.doc (doc "Macro for definint tests."
(context: "Simple macros and constructs"
@@ -188,9 +184,9 @@
)}
(with-gensyms [g!context g!test g!error]
(wrap (list (` (def: #export (~@ g!context)
- {#..test (.._code/text_ (~ description))}
+ {#..test ((~! code.text) (~ description))}
(IO Test)
- (io (case ("lux try" [(io (do ..Monad<Random> [] (~ test)))])
+ (io (case ("lux try" [(io (do (~! r.Monad<Random>) [] (~ test)))])
(#.Right (~@ g!test))
(~@ g!test)
@@ -212,13 +208,10 @@
(list.filter product.left)
(list/map product.right)))))
-(def: #hidden _composeT_ (-> Text Text Text) (:: text.Monoid<Text> compose))
-(def: #hidden _%i_ (-> Int Text) %i)
-
(syntax: #export (run)
{#.doc (doc "Runs all the tests defined on the current module, and in all imported modules."
(run))}
- (with-gensyms [g!successes g!failures g!total-successes g!total-failures]
+ (with-gensyms [g!successes g!failures g!total-successes g!total-failures g!text/compose]
(do @
[current-module macro.current-module-name
modules (macro.imported-modules current-module)
@@ -237,23 +230,24 @@
[(~' #let) [(~@ g!total-successes) +0
(~@ g!total-failures) +0]
(~+ (list/join (list/map (function [group]
- (list (` [(~@ g!successes) (~@ g!failures)]) (` (run' (list (~+ group))))
+ (list (` [(~@ g!successes) (~@ g!failures)]) (` ((~! run') (list (~+ group))))
(' #let) (` [(~@ g!total-successes) (n/+ (~@ g!successes) (~@ g!total-successes))
(~@ g!total-failures) (n/+ (~@ g!failures) (~@ g!total-failures))])))
groups)))]
- (exec (log! ($_ _composeT_
- "Test-suite finished."
- "\n"
- (_%i_ (nat-to-int (~@ g!total-successes)))
- " out of "
- (_%i_ (nat-to-int (n/+ (~@ g!total-failures)
- (~@ g!total-successes))))
- " tests passed."
- "\n"
- (_%i_ (nat-to-int (~@ g!total-failures))) " tests failed."))
+ (exec (let [(~@ g!text/compose) (:: (~! text.Monoid<Text>) (~' compose))]
+ (log! ($_ (~@ g!text/compose)
+ "Test-suite finished."
+ "\n"
+ ((~! %i) (nat-to-int (~@ g!total-successes)))
+ " out of "
+ ((~! %i) (nat-to-int (n/+ (~@ g!total-failures)
+ (~@ g!total-successes))))
+ " tests passed."
+ "\n"
+ ((~! %i) (nat-to-int (~@ g!total-failures))) " tests failed.")))
(promise.future (if (n/> +0 (~@ g!total-failures))
- ..die
- ..exit))))
+ (~! ..die)
+ (~! ..exit)))))
[])))))))))
(def: #export (seq left right)