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
|
(.module:
[library
[lux #*
["_" test (#+ Test)]
[control
["." try]]
[data
["." text]]]]
[\\library
["." /
["n" nat]
["i" int]
["r" rev]
["f" frac]]]
["." / #_
["#." i8]
["#." i16]
["#." i32]
["#." i64]
["#." nat]
["#." int]
["#." rev]
["#." frac]
["#." ratio]
["#." complex]])
(def: clean_commas
(-> Text Text)
(text.replace_all "," ""))
(def: #export test
Test
(<| (_.covering /._)
($_ _.and
(_.cover [/.bin]
(`` (and (~~ (template [<=> <codec> <number>]
[(case (\ <codec> decode (..clean_commas <number>))
(#try.Success actual)
(<=> (/.bin <number>) actual)
(#try.Failure error)
false)]
[n.= n.binary "11001001"]
[n.= n.binary "11,00,10,01"]
[i.= i.binary "+11001001"]
[i.= i.binary "-11,00,10,01"]
[r.= r.binary ".11001001"]
[r.= r.binary ".11,00,10,01"]
[f.= f.binary "+1100.1001"]
[f.= f.binary "-11,00.10,01"]
)))))
(_.cover [/.oct]
(`` (and (~~ (template [<=> <codec> <number>]
[(case (\ <codec> decode (..clean_commas <number>))
(#try.Success actual)
(<=> (/.oct <number>) actual)
(#try.Failure error)
false)]
[n.= n.octal "615243"]
[n.= n.octal "615,243"]
[i.= i.octal "+615243"]
[i.= i.octal "-615,243"]
[r.= r.octal ".615243"]
[r.= r.octal ".615,243"]
[f.= f.octal "+6152.43"]
[f.= f.octal "-61,52.43"]
)))))
(_.cover [/.hex]
(`` (and (~~ (template [<=> <codec> <number>]
[(case (\ <codec> decode (..clean_commas <number>))
(#try.Success actual)
(<=> (/.hex <number>) actual)
(#try.Failure error)
false)]
[n.= n.hex "deadBEEF"]
[n.= n.hex "dead,BEEF"]
[i.= i.hex "+deadBEEF"]
[i.= i.hex "-dead,BEEF"]
[r.= r.hex ".deadBEEF"]
[r.= r.hex ".dead,BEEF"]
[f.= f.hex "+dead.BEEF"]
[f.= f.hex "-dead,BE.EF"]
)))))
/i8.test
/i16.test
/i32.test
/i64.test
/nat.test
/int.test
/rev.test
/frac.test
/ratio.test
/complex.test
)))
|