diff options
Diffstat (limited to 'stdlib/source/lux/test.lux')
-rw-r--r-- | stdlib/source/lux/test.lux | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux index 8bb0a71a3..26e99fbce 100644 --- a/stdlib/source/lux/test.lux +++ b/stdlib/source/lux/test.lux @@ -33,12 +33,12 @@ (type: #export Test (r.Random (Promise [Counters Text]))) -(def: pcg-32-magic-inc Nat +12345) +(def: pcg-32-magic-inc Nat 12345) ## [Values] -(def: success Counters [+1 +0]) -(def: failure Counters [+0 +1]) -(def: start Counters [+0 +0]) +(def: success Counters [1 0]) +(def: failure Counters [0 1]) +(def: start Counters [0 0]) (def: (add-counters [s f] [ts tf]) (-> Counters Counters Counters) @@ -87,7 +87,7 @@ (def: failed? (-> Counters Bit) - (|>> product.right (n/> +0))) + (|>> product.right (n/> 0))) (def: #export (seed value test) (-> Seed Test Test) @@ -103,10 +103,10 @@ (def: #export (times amount test) (-> Nat Test Test) - (cond (n/= +0 amount) + (cond (n/= 0 amount) (fail "Cannot try a test 0 times.") - (n/= +1 amount) + (n/= 1 amount) test ## else @@ -126,23 +126,23 @@ (context: "Simple macros and constructs" ($_ seq (test "Can write easy loops for iterative programming." - (i/= 1000 - (loop [counter 0 - value 1] - (if (i/< 3 counter) - (recur (inc counter) (i/* 10 value)) + (i/= +1000 + (loop [counter +0 + value +1] + (if (i/< +3 counter) + (recur (inc counter) (i/* +10 value)) value)))) (test "Can create lists easily through macros." - (and (case (list 1 2 3) - (#.Cons 1 (#.Cons 2 (#.Cons 3 #.Nil))) + (and (case (list +1 +2 +3) + (#.Cons +1 (#.Cons +2 (#.Cons +3 #.Nil))) #1 _ #0) - (case (list& 1 2 3 (list 4 5 6)) - (#.Cons 1 (#.Cons 2 (#.Cons 3 (#.Cons 4 (#.Cons 5 (#.Cons 6 #.Nil)))))) + (case (list& +1 +2 +3 (list +4 +5 +6)) + (#.Cons +1 (#.Cons +2 (#.Cons +3 (#.Cons +4 (#.Cons +5 (#.Cons +6 #.Nil)))))) #1 _ @@ -167,7 +167,7 @@ "By default, random tests will be tried 100 times, you can specify the amount you want:" (context: "Addition & Substraction" - (<| (times +1234) + (<| (times 1234) (do @ [x (:: @ map <prep> rand-gen) y (:: @ map <prep> rand-gen)] @@ -177,7 +177,7 @@ "If a test fails, you'll be shown a seed that you can then use to reproduce a failing scenario." (context: "Addition & Substraction" - (<| (seed +987654321) + (<| (seed 987654321) (do @ [x (:: @ map <prep> rand-gen) y (:: @ map <prep> rand-gen)] @@ -217,8 +217,8 @@ (def: (success-message successes failures) (-> Nat Nat Text) (format "Test-suite finished." "\n" - (%i (.int successes)) " out of " (%i (.int (n/+ failures successes))) " tests passed." "\n" - (%i (.int failures)) " tests failed." "\n")) + (%n successes) " out of " (%n (n/+ failures successes)) " tests passed." "\n" + (%n failures) " tests failed." "\n")) (syntax: #export (run) {#.doc (doc "Runs all the tests defined on the current module, and in all imported modules." @@ -235,8 +235,8 @@ (:: @ map list/join)))] (wrap (list (` (: (~! (IO Any)) ((~! io) (exec ((~! do) (~! promise.Monad<Promise>) - [(~' #let) [(~ g!total-successes) +0 - (~ g!total-failures) +0] + [(~' #let) [(~ g!total-successes) 0 + (~ g!total-failures) 0] (~+ (|> tests (list/map (function (_ [module-name test desc]) (` [(~ (code.text module-name)) (~ (code.identifier [module-name test])) (~ (code.text desc))]))) @@ -248,9 +248,9 @@ list/join))] (exec (log! ((~! success-message) (~ g!total-successes) (~ g!total-failures))) ((~! promise.future) - ((~! io.exit) (if (n/> +0 (~ g!total-failures)) - 1 - 0))))) + ((~! io.exit) (if (n/> 0 (~ g!total-failures)) + +1 + +0))))) []))))))))) (def: #export (seq left right) |