blob: 2bfd265f8fd804c35fffdc44607feb17ad0a72d0 (
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
|
(.require
[library
[lux (.except)
["_" test (.only Test)]
[abstract
[monad (.only do)]
[\\specification
["$[0]" equivalence]]]
[math
["[0]" random]
[number
["n" nat]
["i" int]]]]]
[\\library
["[0]" /]])
(def .public test
Test
(<| (_.covering /._)
(_.for [.Tuple .And])
(do random.monad
[expected random.nat
shift random.nat
dummy (random.only (|>> (n.= expected) not)
random.nat)]
(all _.and
(_.for [/.equivalence]
($equivalence.spec (/.equivalence n.equivalence i.equivalence)
(random.and random.nat random.int)))
(do random.monad
[left random.int
right random.nat]
(_.coverage [/.hash]
(let [hash (/.hash i.hash n.hash)]
(n.= (n.+ (at i.hash hash left)
(at n.hash hash right))
(at hash hash [left right])))))
(<| (_.coverage [/.left])
(n.= expected (/.left [expected dummy])))
(<| (_.coverage [/.right])
(n.= expected (/.right [dummy expected])))
(<| (_.coverage [/.forked])
(let [[left right] ((/.forked (n.+ shift) (n.- shift)) expected)]
(and (n.= (n.+ shift expected)
left)
(n.= (n.- shift expected)
right))))
(do random.monad
[left random.nat
right random.nat]
(all _.and
(<| (_.coverage [/.swapped])
(let [pair [left right]]
(and (n.= (/.left pair)
(/.right (/.swapped pair)))
(n.= (/.right pair)
(/.left (/.swapped pair))))))
(<| (_.coverage [/.uncurried])
(n.= (n.+ left right)
((/.uncurried n.+) [left right])))
(<| (_.coverage [/.curried])
(n.= (n.+ left right)
((/.curried (/.uncurried n.+)) left right)))
(<| (_.coverage [/.then])
(let [[left' right'] (/.then (n.+ shift) (n.- shift) [left right])]
(and (n.= (n.+ shift left) left')
(n.= (n.- shift right) right'))))))
))))
|