blob: 95896cb7c382a646033dae7642cf8be796bd4802 (
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
|
(.require
[library
[lux (.except)
["_" test (.only Test)]
["@" target]
["[0]" meta]
[data
["[0]" text (.use "[1]#[0]" equivalence)
["%" \\format (.only format)]]
[collection
["[0]" list (.use "[1]#[0]" mix)]]]
[macro
["[0]" code]]
[math
["[0]" random (.use "[1]#[0]" functor)]
[number
["n" nat]
["i" int]
["r" rev]
["f" frac]]]]]
[\\library
["[0]" /]])
(def .public test
Test
(<| (_.covering /._)
(for @.old (_.property "PLACEHOLDER" true))
(_.for [meta.eval])
(`` (all _.and
(~~ (with_template [<static> <random> <=> <+> <tag>]
[(_.coverage [<static> <random>]
(with_expansions [<left> (<random>)
<right> (<random>)
<l+r> (<static> (<+> <left> <right>))]
(case (' <l+r>)
[_ {<tag> l+r}]
(<=> l+r (<+> <left> <right>))
_
false)))]
[/.nat /.random_nat n.= n.+ .#Nat]
[/.int /.random_int i.= i.+ .#Int]
[/.rev /.random_rev r.= r.+ .#Rev]
))
(_.coverage [/.frac /.random_frac]
(with_expansions [<left> (/.random_frac)
<right> (/.random_frac)
<l+r> (/.frac (f.+ <left> <right>))]
(case (' <l+r>)
[_ {.#Frac l+r}]
(or (f.= l+r (f.+ <left> <right>))
(and (f.not_a_number? l+r)
(f.not_a_number? (f.+ <left> <right>))
(or (f.not_a_number? <left>)
(f.not_a_number? <right>))))
_
false)))
(_.coverage [/.text /.random]
(with_expansions [<left> (/.random code.text (random.alpha_numeric 1))
<right> (/.random code.text (random.alpha_numeric 1))
<l+r> (/.text (format <left> <right>))]
(case (' <l+r>)
[_ {.#Text l+r}]
(text#= l+r (format <left> <right>))
_
false)))
(_.coverage [/.randoms]
(with_expansions [<amount> (/.random code.nat
(random#each (|>> (n.% 10) ++) random.nat))
l/* (/.randoms code.nat (random.list <amount> random.nat))]
(and (n.= <amount> (list.size (list l/*)))
(n.= (list#mix n.+ 0 (list l/*))
(all n.+ l/*)))))
(_.coverage [/.literal]
(with_expansions [<left> (/.random code.text (random.alpha_numeric 1))
<right> (/.random code.text (random.alpha_numeric 1))
<l+r> (/.literal code.text (format <left> <right>))]
(case (' <l+r>)
[_ {.#Text l+r}]
(text#= l+r (format <left> <right>))
_
false)))
(_.coverage [/.literals]
(with_expansions [l/0 (/.random_nat)
l/1 (/.random_nat)
l/2 (/.random_nat)
l/* (/.literals code.nat (list l/0 l/1 l/2))]
(n.= (all n.+ l/0 l/1 l/2)
(all n.+ l/*))))
))))
|