aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/test.lux
diff options
context:
space:
mode:
authorEduardo Julian2022-07-30 23:13:24 -0400
committerEduardo Julian2022-07-30 23:13:24 -0400
commit6ec8f5d2f6cbf8db45f91e5c4b48c6ec17659f72 (patch)
tree4af1db76b4aec333114f236bc88b9ccddc643e26 /stdlib/source/test/lux/test.lux
parent2d125c27e1ceb0adc14fd82f6984b70a12eda650 (diff)
Extracted test-tallying machinery into its own module.
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/test.lux103
1 files changed, 52 insertions, 51 deletions
diff --git a/stdlib/source/test/lux/test.lux b/stdlib/source/test/lux/test.lux
index 956969668..6d2939185 100644
--- a/stdlib/source/test/lux/test.lux
+++ b/stdlib/source/test/lux/test.lux
@@ -21,14 +21,15 @@
["n" nat]]]]]
[\\library
["[0]" / (.only)
- ["[0]" unit]]])
+ ["[0]" unit]
+ ["[0]" tally (.only Tally)]]])
(def (verify expected_message/0 expected_message/1 successes failures [tally message])
- (-> Text Text Nat Nat [unit.Tally Text] Bit)
+ (-> Text Text Nat Nat [Tally Text] Bit)
(and (text.contains? expected_message/0 message)
(text.contains? expected_message/1 message)
- (n.= successes (the unit.#successes tally))
- (n.= failures (the unit.#failures tally))))
+ (n.= successes (the tally.#successes tally))
+ (n.= failures (the tally.#failures tally))))
(def unit_test
/.Test
@@ -40,13 +41,13 @@
(in (do async.monad
[[success_tally success_message] (unit.test expected_message/0 true)
[failure_tally failure_message] (unit.test expected_message/0 false)]
- (unit.coverage [unit.test unit.Tally]
+ (unit.coverage [unit.test tally.Tally]
(and (text.ends_with? expected_message/0 success_message)
(text.ends_with? expected_message/0 failure_message)
- (and (n.= 1 (the unit.#successes success_tally))
- (n.= 0 (the unit.#failures success_tally)))
- (and (n.= 0 (the unit.#successes failure_tally))
- (n.= 1 (the unit.#failures failure_tally)))))))
+ (and (n.= 1 (the tally.#successes success_tally))
+ (n.= 0 (the tally.#failures success_tally)))
+ (and (n.= 0 (the tally.#successes failure_tally))
+ (n.= 1 (the tally.#failures failure_tally)))))))
(in (do async.monad
[tt (unit.and (unit.test expected_message/0 true)
(unit.test expected_message/1 true))
@@ -84,10 +85,10 @@
[[pre_tally pre_message] pre
[post_tally post_message] post]
(unit.coverage [/.seed]
- (and (and (n.= 1 (the unit.#successes pre_tally))
- (n.= 0 (the unit.#failures pre_tally)))
- (and (n.= 1 (the unit.#successes post_tally))
- (n.= 0 (the unit.#failures post_tally)))))))))
+ (and (and (n.= 1 (the tally.#successes pre_tally))
+ (n.= 0 (the tally.#failures pre_tally)))
+ (and (n.= 1 (the tally.#successes post_tally))
+ (n.= 0 (the tally.#failures post_tally)))))))))
(def times
/.Test
@@ -98,8 +99,8 @@
[[tally error] times_unit_test]
(unit.coverage [/.must_try_test_at_least_once]
(and (text.contains? (the exception.#label /.must_try_test_at_least_once) error)
- (n.= 0 (the unit.#successes tally))
- (n.= 1 (the unit.#failures tally)))))))
+ (n.= 0 (the tally.#successes tally))
+ (n.= 1 (the tally.#failures tally)))))))
(do [! random.monad]
[expected (at ! each (|>> (n.% 10) ++) random.nat)
.let [counter (is (Atom Nat)
@@ -114,8 +115,8 @@
actual (async.future (atom.read! counter))]
(unit.coverage [/.times]
(and (n.= expected actual)
- (n.= 1 (the unit.#successes tally))
- (n.= 0 (the unit.#failures tally)))))))
+ (n.= 1 (the tally.#successes tally))
+ (n.= 0 (the tally.#failures tally)))))))
))
(def in_parallel
@@ -137,8 +138,8 @@
actual (async.future (atom.read! counter))]
(unit.coverage [/.in_parallel]
(and (n.= expected actual)
- (n.= expected (the unit.#successes tally))
- (n.= 0 (the unit.#failures tally)))))))
+ (n.= expected (the tally.#successes tally))
+ (n.= 0 (the tally.#failures tally)))))))
(do [! random.monad]
[expected (at ! each (|>> (n.% 10) ++) random.nat)
.let [counter (is (Atom Nat)
@@ -157,8 +158,8 @@
(unit.coverage [/.error_during_execution]
(let [correct_error! (text.contains? (the exception.#label /.error_during_execution) error)
no_complete_run! (n.= 0 actual)
- no_successes! (n.= 0 (the unit.#successes tally))
- ran_all_tests! (n.= expected (the unit.#failures tally))]
+ no_successes! (n.= 0 (the tally.#successes tally))
+ ran_all_tests! (n.= expected (the tally.#failures tally))]
(and correct_error!
no_complete_run!
no_successes!
@@ -178,10 +179,10 @@
[[not_covering _] not_covering
[covering _] covering]
(unit.coverage [/.covering]
- (and (and (set.empty? (the unit.#expected not_covering))
- (set.empty? (the unit.#actual not_covering)))
- (and (not (set.empty? (the unit.#expected covering)))
- (set.empty? (the unit.#actual covering))))))))
+ (and (and (set.empty? (the tally.#expected not_covering))
+ (set.empty? (the tally.#actual not_covering)))
+ (and (not (set.empty? (the tally.#expected covering)))
+ (set.empty? (the tally.#actual covering))))))))
(do random.monad
[not_covering (/.covering .._ (/.test "" true))
covering (/.covering .._ (/.coverage [..dummy_target] true))]
@@ -189,10 +190,10 @@
[[not_covering _] not_covering
[covering _] covering]
(unit.coverage [/.coverage]
- (and (and (not (set.empty? (the unit.#expected not_covering)))
- (not (set.member? (the unit.#actual not_covering) (symbol ..dummy_target))))
- (and (not (set.empty? (the unit.#expected covering)))
- (set.member? (the unit.#actual covering) (symbol ..dummy_target))))))))
+ (and (and (not (set.empty? (the tally.#expected not_covering)))
+ (not (set.member? (the tally.#actual not_covering) (symbol ..dummy_target))))
+ (and (not (set.empty? (the tally.#expected covering)))
+ (set.member? (the tally.#actual covering) (symbol ..dummy_target))))))))
(do random.monad
[not_covering (/.covering .._ (/.test "" true))
covering (/.covering .._ (in (unit.coverage [..dummy_target] true)))]
@@ -200,10 +201,10 @@
[[not_covering _] not_covering
[covering _] covering]
(unit.coverage [unit.coverage]
- (and (and (not (set.empty? (the unit.#expected not_covering)))
- (not (set.member? (the unit.#actual not_covering) (symbol ..dummy_target))))
- (and (not (set.empty? (the unit.#expected covering)))
- (set.member? (the unit.#actual covering) (symbol ..dummy_target))))))))
+ (and (and (not (set.empty? (the tally.#expected not_covering)))
+ (not (set.member? (the tally.#actual not_covering) (symbol ..dummy_target))))
+ (and (not (set.empty? (the tally.#expected covering)))
+ (set.member? (the tally.#actual covering) (symbol ..dummy_target))))))))
(do random.monad
[not_covering (/.covering .._ (/.test "" true))
covering (/.covering .._ (/.for [..dummy_target] (/.test "" true)))]
@@ -211,10 +212,10 @@
[[not_covering _] not_covering
[covering _] covering]
(unit.coverage [/.for]
- (and (and (not (set.empty? (the unit.#expected not_covering)))
- (not (set.member? (the unit.#actual not_covering) (symbol ..dummy_target))))
- (and (not (set.empty? (the unit.#expected covering)))
- (set.member? (the unit.#actual covering) (symbol ..dummy_target))))))))
+ (and (and (not (set.empty? (the tally.#expected not_covering)))
+ (not (set.member? (the tally.#actual not_covering) (symbol ..dummy_target))))
+ (and (not (set.empty? (the tally.#expected covering)))
+ (set.member? (the tally.#actual covering) (symbol ..dummy_target))))))))
))
(def .public test
@@ -241,10 +242,10 @@
(unit.coverage [/.test]
(and (text.ends_with? (%.text expected_message/0) success_message)
(text.ends_with? (%.text expected_message/0) failure_message)
- (and (n.= 1 (the unit.#successes success_tally))
- (n.= 0 (the unit.#failures success_tally)))
- (and (n.= 0 (the unit.#successes failure_tally))
- (n.= 1 (the unit.#failures failure_tally))))))))
+ (and (n.= 1 (the tally.#successes success_tally))
+ (n.= 0 (the tally.#failures success_tally)))
+ (and (n.= 0 (the tally.#successes failure_tally))
+ (n.= 1 (the tally.#failures failure_tally))))))))
(do !
[tt (/.and (/.test expected_message/0 true)
(/.test expected_message/1 true))
@@ -275,18 +276,18 @@
(text.contains? expected_message/0 success_message))
(and (text.contains? expected_context failure_message)
(text.contains? expected_message/0 failure_message))
- (and (n.= 1 (the unit.#successes success_tally))
- (n.= 0 (the unit.#failures success_tally)))
- (and (n.= 0 (the unit.#successes failure_tally))
- (n.= 1 (the unit.#failures failure_tally))))))))
+ (and (n.= 1 (the tally.#successes success_tally))
+ (n.= 0 (the tally.#failures success_tally)))
+ (and (n.= 0 (the tally.#successes failure_tally))
+ (n.= 1 (the tally.#failures failure_tally))))))))
(do !
[failure_unit_test (/.failure expected_message/0)]
(in (do async.monad
[[failure_tally failure_message] failure_unit_test]
(unit.coverage [/.failure]
(and (text.contains? expected_message/0 failure_message)
- (and (n.= 0 (the unit.#successes failure_tally))
- (n.= 1 (the unit.#failures failure_tally))))))))
+ (and (n.= 0 (the tally.#successes failure_tally))
+ (n.= 1 (the tally.#failures failure_tally))))))))
(do !
[success_unit_test (/.lifted expected_message/0 (in true))
failure_unit_test (/.lifted expected_message/0 (in false))]
@@ -296,10 +297,10 @@
(unit.coverage [/.lifted]
(and (text.contains? expected_message/0 success_message)
(text.contains? expected_message/0 failure_message)
- (and (n.= 1 (the unit.#successes success_tally))
- (n.= 0 (the unit.#failures success_tally)))
- (and (n.= 0 (the unit.#successes failure_tally))
- (n.= 1 (the unit.#failures failure_tally))))))))
+ (and (n.= 1 (the tally.#successes success_tally))
+ (n.= 0 (the tally.#failures success_tally)))
+ (and (n.= 0 (the tally.#successes failure_tally))
+ (n.= 1 (the tally.#failures failure_tally))))))))
..times
..in_parallel
..coverage