aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/test
diff options
context:
space:
mode:
authorEduardo Julian2022-11-05 21:23:20 -0400
committerEduardo Julian2022-11-05 21:23:20 -0400
commitfd8ea1e1b9cae781abe42aeadda2e0ef149994d6 (patch)
tree7fdc152ac481d4f2a8b7be12c98d11a8c644f541 /stdlib/source/library/lux/test
parent736521eb56a45122eb0a545b677d3ffca1451080 (diff)
Property-based testing can now log/print successful seeds from run.
Diffstat (limited to 'stdlib/source/library/lux/test')
-rw-r--r--stdlib/source/library/lux/test/property.lux31
1 files changed, 23 insertions, 8 deletions
diff --git a/stdlib/source/library/lux/test/property.lux b/stdlib/source/library/lux/test/property.lux
index 732be561f..db3adfb11 100644
--- a/stdlib/source/library/lux/test/property.lux
+++ b/stdlib/source/library/lux/test/property.lux
@@ -108,8 +108,19 @@
(exception.def .public must_try_test_at_least_once)
-(def .public (times amount test)
- (-> Nat Test Test)
+(type .public Success_Policy
+ Bit)
+
+(def .public ignore_success
+ Success_Policy
+ #0)
+
+(def .public announce_success
+ Success_Policy
+ #1)
+
+(def .public (times amount announce_success? test)
+ (-> Nat Success_Policy Test Test)
(when amount
0 (..failure (exception.error ..must_try_test_at_least_once []))
_ (do random.monad
@@ -120,12 +131,16 @@
[[tally documentation] instance]
(if (..failed? tally)
(in [tally (times_failure seed documentation)])
- (when amount
- 1 instance
- _ (|> test
- (times (-- amount))
- (random.result prng')
- product.right))))])))))
+ (exec
+ (if announce_success?
+ (debug.log! (format "Succeeded with this seed: " (%.nat seed)))
+ [])
+ (when amount
+ 1 instance
+ _ (|> test
+ (times (-- amount) announce_success?)
+ (random.result prng')
+ product.right)))))])))))
(def (description duration tally)
(-> Duration Tally Text)