blob: e24d6f52fe9db252877ed0f27ccf0ac13c03fb23 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
(.require
[library
[lux (.except)
[abstract
[monad (.only do)]]
[control
["[0]" try]
["[0]" exception]]
[data
["[0]" text]]
[math
["[0]" random]
[number
["n" nat]]]
[test
["_" property (.only Test)]]]]
[\\library
["[0]" /]])
(def .public test
Test
(<| (_.covering /._)
(do [! random.monad]
[expected random.nat
error_message (random.upper_case 5)])
(all _.and
(_.coverage [/.pre /.pre_condition_failed]
(when (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]
(when (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)))))
(_.coverage [/.assert!]
(and (when (try (/.assert! error_message true))
{try.#Success actual}
true
{try.#Failure error}
false)
(when (try (/.assert! error_message false))
{try.#Success actual}
false
{try.#Failure error}
(text.contains? error_message error))))
)))
|