diff options
author | Eduardo Julian | 2017-10-20 19:24:01 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-10-20 19:24:01 -0400 |
commit | 40190ba6f026826775e54d9e71fe4f38175b76ba (patch) | |
tree | aef32969df4fd60a2454a160e5864d69fc0d7f28 /stdlib/source | |
parent | e9368bc5f75345c81bd7ded21e07a4436641821a (diff) |
- Restored the capacity to get the failing seed.
Diffstat (limited to 'stdlib/source')
-rw-r--r-- | stdlib/source/lux/test.lux | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux index 5568478a0..2d171f12f 100644 --- a/stdlib/source/lux/test.lux +++ b/stdlib/source/lux/test.lux @@ -49,7 +49,7 @@ (-> Counters Counters Counters) [(n.+ s ts) (n.+ f tf)]) -(def: (fail message) +(def: #export (fail message) (All [a] (-> Text Test)) (|> [failure (format " [Error] " message)] (:: Monad<Promise> wrap) @@ -109,33 +109,17 @@ test ## else - (function [prng] - (let [[prng' instance] (r;run prng test)] - [prng' (do Monad<Promise> - [[counters documentation] instance] - (if (failed? counters) - (wrap [counters documentation]) - (product;right (r;run prng' (times (n.dec amount) test)))))])))) + (do r;Monad<Random> + [seed r;nat] + (function [prng] + (let [[prng' instance] (r;run (r;pcg-32 [pcg-32-magic-inc seed]) test)] + [prng' (do Monad<Promise> + [[counters documentation] instance] + (if (failed? counters) + (wrap [counters (format "Failed with this seed: " (%n seed) "\n" documentation)]) + (product;right (r;run prng' (times (n.dec amount) test)))))]))))) ## [Syntax] -(def: #hidden (try-test test) - (-> (IO Test) (IO Test)) - (do Monad<IO> - [now instant;now - #let [seed (|> now instant;to-millis int-to-nat)]] - (io (do r;Monad<Random> - [instance (case (_lux_proc ["lux" "try"] [test]) - (#e;Success test) - test - - (#e;Error error) - (fail error))] - (wrap (do Monad<Promise> - [[counter documentation] instance] - (if (failed? counter) - (wrap [counter (format "Context failed with this seed: " (%n seed) "\n" documentation)]) - (wrap [counter documentation])))))))) - (def: #hidden _code/text_ code;text) (syntax: #export (context: description test) @@ -202,11 +186,16 @@ (and (|> x (- y) (+ y) (= x)) (|> x (+ y) (- y) (= x))))))) )} - (with-gensyms [g!test] - (wrap (list (` (def: #export (~ g!test) + (with-gensyms [g!context g!test g!error] + (wrap (list (` (def: #export (~ g!context) {#;;test (;;_code/text_ (~ description))} (IO Test) - (;;try-test (io (do ;;Monad<Random> [] (~ test)))))))))) + (io (case ((~' _lux_proc) ["lux" "try"] [(io (do ;;Monad<Random> [] (~ test)))]) + (#;Right (~ g!test)) + (~ g!test) + + (#;Left (~ g!error)) + (;;fail (~ g!error)))))))))) (def: (exported-tests module-name) (-> Text (Meta (List [Text Text Text]))) |