blob: 1c4c7d2ed2dfd99e8e8db4d53f07328c2fe02afd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
(.using
[library
[lux (.full)
["_" test (.only Test)]
[abstract
[monad (.only do)]]
[control
["[0]" try]
["[0]" exception]]
[data
["[0]" text]]
[math
["[0]" random]
[number
["n" nat]]]]]
[\\library
["[0]" /]])
(def: .public test
Test
(<| (_.covering /._)
(do [! random.monad]
[expected random.nat])
(all _.and
(_.coverage [/.pre /.pre_condition_failed]
(case (try (/.pre (n.even? expected)
true))
{try.#Success output}
output
{try.#Failure error}
(and (text.contains? (the exception.#label /.pre_condition_failed)
error)
(not (n.even? expected)))))
(_.coverage [/.post /.post_condition_failed]
(case (try (/.post n.odd?
expected))
{try.#Success actual}
(same? expected actual)
{try.#Failure error}
(and (text.contains? (the exception.#label /.post_condition_failed)
error)
(not (n.odd? expected)))))
)))
|