blob: f23767283150d912e7a18b686cceef29b8b84b7c (
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
|
(.using
[library
[lux "*"
["_" test {"+" Test}]
[abstract
[monad {"+" do}]
[\\specification
["$[0]" equivalence]
["$[0]" functor {"+" Injection}]]]
[control
["[0]" maybe]]
[data
["[0]" bit ("[1]#[0]" equivalence)]]
[math
["[0]" random]
[number
["n" nat]]]]]
[\\library
["[0]" /]])
(def: (injection value)
(Injection /.Stack)
(/.top value /.empty))
(def: .public test
Test
(<| (_.covering /._)
(_.for [/.Stack])
(do random.monad
[size (# random.monad each (n.% 100) random.nat)
sample (random.stack size random.nat)
expected_top random.nat]
(all _.and
(_.for [/.equivalence]
($equivalence.spec (/.equivalence n.equivalence) (random.stack size random.nat)))
(_.for [/.functor]
($functor.spec ..injection /.equivalence /.functor))
(_.cover [/.size]
(n.= size (/.size sample)))
(_.cover [/.empty?]
(bit#= (n.= 0 (/.size sample))
(/.empty? sample)))
(_.cover [/.empty]
(/.empty? /.empty))
(_.cover [/.value]
(case (/.value sample)
{.#None}
(/.empty? sample)
{.#Some _}
(not (/.empty? sample))))
(_.cover [/.next]
(case (/.next sample)
{.#None}
(/.empty? sample)
{.#Some [top remaining]}
(# (/.equivalence n.equivalence) =
sample
(/.top top remaining))))
(_.cover [/.top]
(case (/.next (/.top expected_top sample))
{.#Some [actual_top actual_sample]}
(and (same? expected_top actual_top)
(same? sample actual_sample))
{.#None}
false))
))))
|