blob: 86d28d753bb977271f9ebb79f1b3f85e8159531f (
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
|
(.module:
[lux #*
["_" test (#+ Test)]
[abstract
[monad (#+ do)]
{[0 #spec]
[/
["$." functor (#+ Injection Comparison)]
["$." apply]
["$." monad]
["$." equivalence]]}]
[data
["." product]]
[math
["." random (#+ Random)]
[number
["n" nat]]]]
{1
["." / (#+ Lazy)]})
(def: injection
(Injection Lazy)
(|>> /.freeze))
(def: comparison
(Comparison Lazy)
(function (_ ==)
(\ (/.equivalence ==) =)))
(def: #export lazy
(All [a] (-> (Random a) (Random (Lazy a))))
(\ random.functor map (|>> /.freeze)))
(def: #export test
Test
(with_expansions [<eager> (: [Nat Nat]
[(n.+ left right)
(n.* left right)])]
(<| (_.covering /._)
(do random.monad
[left random.nat
right random.nat
#let [expected <eager>]]
(_.for [/.Lazy]
($_ _.and
(_.for [/.equivalence]
($equivalence.spec (/.equivalence n.equivalence) (..lazy random.nat)))
(_.for [/.functor]
($functor.spec ..injection ..comparison /.functor))
(_.for [/.apply]
($apply.spec ..injection ..comparison /.apply))
(_.for [/.monad]
($monad.spec ..injection ..comparison /.monad))
(_.cover [/.freeze]
(let [lazy (/.freeze <eager>)
(^open "\=") (product.equivalence n.equivalence n.equivalence)]
(\= expected
(/.thaw lazy))))
(_.cover [/.thaw]
(let [lazy (/.freeze <eager>)]
(and (not (is? expected
(/.thaw lazy)))
(is? (/.thaw lazy)
(/.thaw lazy)))))
))))))
|