blob: 0931481da205beb6c74f9fae8ef4f269e67aaf88 (
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
(.module:
[lux #*
["_" test (#+ Test)]
["." debug]
[abstract
codec
[monad (#+ do)]
["." equivalence (#+ Equivalence)
{[0 #poly]
["poly/#" /]}]
{[0 #spec]
[/
["$." equivalence]
["$." codec]]}]
[control
pipe
["." try]
["p" parser
## TODO: Get rid of this import ASAP
[json (#+)]]]
[data
["." bit]
["." maybe]
["." text
["%" format (#+ format)]]
[format
[json (#+)
{[0 #poly]
["." /]}]]
[collection
[row (#+ row)]
["d" dictionary]
["." list]]]
[macro
[poly (#+ derived:)]]
[type
["." unit]]
[math
["." random (#+ Random)]
[number
["n" nat]
["." frac]]]
[time
["ti" instant]
["tda" date]
## ["tdu" duration]
]]
[test
[lux
[time
["_." instant]
## ["_." duration]
]]])
(type: Variant
(#Bit Bit)
(#Text Text)
(#Frac Frac))
(type: #rec Recursive
(#Number Frac)
(#Addition Frac Recursive))
(type: Record
{#bit Bit
#frac Frac
#text Text
#maybe (Maybe Frac)
#list (List Frac)
#dictionary (d.Dictionary Text Frac)
#variant Variant
#tuple [Bit Text Frac]
#recursive Recursive
## #instant ti.Instant
## #duration tdu.Duration
#date tda.Date
#grams (unit.Qty unit.Gram)})
(def: gen_recursive
(Random Recursive)
(random.rec
(function (_ gen_recursive)
(random.or random.safe_frac
(random.and random.safe_frac
gen_recursive)))))
(def: qty
(All [unit] (Random (unit.Qty unit)))
(\ random.monad map (debug.private unit.in) random.int))
(def: gen_record
(Random Record)
(do {! random.monad}
[size (\ ! map (n.% 2) random.nat)]
($_ random.and
random.bit
random.safe_frac
(random.unicode size)
(random.maybe random.safe_frac)
(random.list size random.safe_frac)
(random.dictionary text.hash size (random.unicode size) random.safe_frac)
($_ random.or random.bit (random.unicode size) random.safe_frac)
($_ random.and random.bit (random.unicode size) random.safe_frac)
..gen_recursive
## _instant.instant
## _duration.duration
random.date
..qty
)))
(derived: equivalence
(poly/equivalence.equivalence Record))
(derived: codec
(/.codec Record))
(def: #export test
Test
(<| (_.covering /._)
(_.for [/.codec]
($codec.spec ..equivalence ..codec ..gen_record))))
|