aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux.lux')
-rw-r--r--stdlib/source/test/lux.lux65
1 files changed, 36 insertions, 29 deletions
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index cd77beb6f..de99ee775 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -58,25 +58,9 @@
(template: (!bundle body)
(: Test
(do random.monad
- [_ (wrap [])]
+ [_ (in [])]
body)))
-(def: prelude_macros
- Test
- ($_ _.and
- (do random.monad
- [factor (random\map (|>> (n.% 10) (n.max 1)) random.nat)
- iterations (random\map (n.% 10) random.nat)
- #let [expected (n.* factor iterations)]]
- (_.test "Can write loops."
- (n.= expected
- (loop [counter 0
- value 0]
- (if (n.< iterations counter)
- (recur (inc counter) (n.+ factor value))
- value)))))
- ))
-
(def: sub_tests
Test
(with_expansions [## TODO: Update & expand tests for this
@@ -421,7 +405,7 @@
))))
(/.macro: (identity_macro tokens)
- (\ meta.monad wrap tokens))
+ (\ meta.monad in tokens))
(def: for_macro
Test
@@ -621,8 +605,8 @@
(def: for_static
Test
(do random.monad
- [sample (random.either (wrap option/0)
- (wrap option/1))]
+ [sample (random.either (in option/0)
+ (in option/1))]
($_ _.and
(_.cover [/.static]
(case sample
@@ -862,12 +846,12 @@
(do {! random.monad}
[expected_nat (\ ! map (n.% 1) random.nat)
expected_int (\ ! map (i.% +1) random.int)
- expected_rev (random.either (wrap .5)
- (wrap .25))
- expected_frac (random.either (wrap +0.5)
- (wrap +1.25))
- expected_text (random.either (wrap "+0.5")
- (wrap "+1.25"))]
+ expected_rev (random.either (in .5)
+ (in .25))
+ expected_frac (random.either (in +0.5)
+ (in +1.25))
+ expected_text (random.either (in "+0.5")
+ (in "+1.25"))]
($_ _.and
(_.cover [/.case]
(and (/.case expected_nat
@@ -963,13 +947,35 @@
(/.is? expected_int actual_right)))))
)))
+(def: for_control_flow
+ Test
+ ($_ _.and
+ (do random.monad
+ [factor (random\map (|>> (n.% 10) (n.max 1)) random.nat)
+ iterations (random\map (n.% 10) random.nat)
+ #let [expected (n.* factor iterations)]]
+ (_.cover [/.loop]
+ (n.= expected
+ (/.loop [counter 0
+ value 0]
+ (if (n.< iterations counter)
+ (recur (inc counter) (n.+ factor value))
+ value)))))
+ (do random.monad
+ [pre random.nat
+ post (random.only (|>> (n.= pre) not) random.nat)
+ #let [box (atom.atom pre)]]
+ (_.cover [/.exec]
+ (and (is? pre (io.run (atom.read box)))
+ (/.exec
+ (io.run (atom.write post box))
+ (is? post (io.run (atom.read box)))))))
+ ))
+
(def: test
Test
(<| (_.covering /._)
($_ _.and
- (<| (_.context "Prelude macros.")
- ..prelude_macros)
-
..for_bit
..for_try
..for_list
@@ -988,6 +994,7 @@
..for_expansion
..for_value
..for_case
+ ..for_control_flow
..sub_tests
)))