blob: ed0998646b0591cac82873bbfa475087e694dfe5 (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
(.require
[library
[lux (.except)
["_" test (.only Test)]
[abstract
[monad (.only do)]
[\\specification
["$[0]" equivalence]
["$[0]" monoid]]]
[control
["<>" parser]
["[0]" try (.use "[1]#[0]" functor)]
["[0]" exception]]
[data
["[0]" text (.only)
["<[1]>" \\parser]]
[collection
["[0]" list]]]
[math
["[0]" random (.only Random) (.use "[1]#[0]" monad)]]
["[0]" meta (.only)
["[0]" code (.only)
["<[1]>" \\parser]]
[macro
[syntax (.only syntax)]
["[0]" expansion]]]]]
[\\library
["[0]" /]])
(def .public (random amount)
(-> Nat (Random /.Configuration))
(case amount
0 (random#in /.empty)
_ (do [! random.monad]
[feature (random.upper_case amount)
value (random.lower_case amount)]
(at ! each (|>> (list.partial [feature value]))
(random (-- amount))))))
(def failure
(syntax (_ [it <code>.any])
(function (_ lux)
(case (expansion.complete it lux)
{try.#Failure error}
{try.#Success [lux (list (code.text error))]}
{try.#Success _}
{try.#Failure ""}))))
(def .public test
Test
(<| (_.covering /._)
(_.for [/.Configuration])
(do [! random.monad]
[expected (..random 5)]
(all _.and
(_.for [/.equivalence]
($equivalence.spec /.equivalence (..random 5)))
(_.for [/.monoid]
($monoid.spec /.equivalence /.monoid (..random 5)))
(_.coverage [/.empty]
(list.empty? /.empty))
(_.coverage [/.format /.parser]
(|> expected
/.format
(<text>.result /.parser)
(try#each (at /.equivalence = expected))
(try.else false)))
(_.coverage [/.for]
(and (and (/.for ["left" "<<<"
"right" ">>>"]
true
... else
false)
(/.for ["left" "<<<"]
true
... else
false)
(/.for ["right" ">>>"]
true
... else
false))
(and (/.for ["yolo" ""]
false
... else
true)
(/.for ["left" "yolo"]
false
... else
true))))
(_.coverage [/.invalid]
(and (text.contains? (the exception.#label /.invalid)
(..failure (/.for)))
(text.contains? (the exception.#label /.invalid)
(..failure (/.for ["left" "yolo"]
... else
false)))))
))))
|