blob: fa863cdae6f17ffb5123553062ab113a5746a9fb (
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
|
(.module:
[lux #*
["_" test (#+ Test)]
[abstract
[monad (#+ do)]
{[0 #spec]
[/
["$." equivalence]
["$." monoid]
["$." functor]
["$." apply]
["$." monad]]}]
[control
["." io ("#\." monad)]
pipe]
[data
["." text]
[number
["n" nat]]
[collection
["." list]]]
[math
["." random (#+ Random)]]]
{1
["." / ("#\." monoid monad)]})
(def: #export test
Test
(<| (_.covering /._)
(_.with-cover [.Maybe]
($_ _.and
(_.with-cover [/.equivalence]
($equivalence.spec (/.equivalence n.equivalence) (random.maybe random.nat)))
(_.with-cover [/.monoid]
($monoid.spec (/.equivalence n.equivalence) /.monoid (random.maybe random.nat)))
(_.with-cover [/.functor]
($functor.spec /\wrap /.equivalence /.functor))
(_.with-cover [/.apply]
($apply.spec /\wrap /.equivalence /.apply))
(_.with-cover [/.monad]
($monad.spec /\wrap /.equivalence /.monad))
(do random.monad
[left random.nat
right random.nat
#let [expected (n.+ left right)]]
(let [lift (/.lift io.monad)]
(_.cover [/.with /.lift]
(|> (io.run (do (/.with io.monad)
[a (lift (io\wrap left))
b (wrap right)]
(wrap (n.+ a b))))
(case> (#.Some actual)
(n.= expected actual)
_
false)))))
(do random.monad
[default random.nat
value random.nat]
(_.cover [/.default]
(and (is? default (/.default default
#.None))
(is? value (/.default default
(#.Some value))))))
(do random.monad
[value random.nat]
(_.cover [/.assume]
(is? value (/.assume (#.Some value)))))
(do random.monad
[value random.nat]
(_.cover [/.to-list]
(\ (list.equivalence n.equivalence) =
(list value)
(/.to-list (#.Some value)))))
))))
|