diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/test/lux.lux | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index 26924ef8e..1e9976f4e 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -19,7 +19,9 @@ [data ["." bit ("#\." equivalence)] ["." text ("#\." equivalence) - ["%" format (#+ format)]]] + ["%" format (#+ format)]] + [collection + ["." list]]] [macro ["." code ("#\." equivalence)]] ["." math @@ -553,6 +555,38 @@ (n.= (n.* (inc expected_left) (dec expected_right)) (actual expected_left expected_right)))))) +(/.template: (!n/+ <left> <right>) + (n.+ <left> <right>)) + +(def: for_template + Test + (`` ($_ _.and + (_.cover [/.template] + (let [bits (list (~~ (/.template [_] + [true] + + [0] [1] [2] + )))] + (and (n.= 3 (list.size bits)) + (list.every? (bit\= true) bits)))) + (do random.monad + [left random.nat + right random.nat] + (_.cover [/.template:] + (n.= (n.+ left right) + (!n/+ left right)))) + (do {! random.monad} + [sample (\ ! map (n.% 5) random.nat)] + (_.cover [/.^template] + (case sample + (/.^template [<case>] + [<case> true]) + ([0] [1] [2] [3] [4]) + + _ + false))) + ))) + (def: test Test (<| (_.covering /._) @@ -577,6 +611,7 @@ ..for_type ..for_i64 ..for_function + ..for_template ..sub_tests ))) |