From 40190ba6f026826775e54d9e71fe4f38175b76ba Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 20 Oct 2017 19:24:01 -0400 Subject: - Restored the capacity to get the failing seed. --- stdlib/source/lux/test.lux | 47 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) (limited to 'stdlib') 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 wrap) @@ -109,33 +109,17 @@ test ## else - (function [prng] - (let [[prng' instance] (r;run prng test)] - [prng' (do Monad - [[counters documentation] instance] - (if (failed? counters) - (wrap [counters documentation]) - (product;right (r;run prng' (times (n.dec amount) test)))))])))) + (do r;Monad + [seed r;nat] + (function [prng] + (let [[prng' instance] (r;run (r;pcg-32 [pcg-32-magic-inc seed]) test)] + [prng' (do Monad + [[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 - [now instant;now - #let [seed (|> now instant;to-millis int-to-nat)]] - (io (do r;Monad - [instance (case (_lux_proc ["lux" "try"] [test]) - (#e;Success test) - test - - (#e;Error error) - (fail error))] - (wrap (do Monad - [[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 [] (~ test)))))))))) + (io (case ((~' _lux_proc) ["lux" "try"] [(io (do ;;Monad [] (~ test)))]) + (#;Right (~ g!test)) + (~ g!test) + + (#;Left (~ g!error)) + (;;fail (~ g!error)))))))))) (def: (exported-tests module-name) (-> Text (Meta (List [Text Text Text]))) -- cgit v1.2.3