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
|
(.using
[library
[lux (.except)
["_" test (.only Test)]
[control
["[0]" try]]
[data
["[0]" text]]]]
[\\library
["[0]" / (.only)
["n" nat]
["i" int]
["r" rev]
["f" frac]]]
["[0]" /
["[1][0]" i8]
["[1][0]" i16]
["[1][0]" i32]
["[1][0]" i64]
["[1][0]" nat]
["[1][0]" int]
["[1][0]" rev]
["[1][0]" frac]
["[1][0]" ratio]
["[1][0]" complex]])
(def: clean_commas
(-> Text Text)
(text.replaced "," ""))
(def: .public test
Test
(<| (_.covering /._)
(all _.and
(_.coverage [/.bin]
(`` (and (~~ (template [<=> <codec> <number>]
[(case (at <codec> decoded (..clean_commas <number>))
{try.#Success actual}
(<=> (/.bin <number>) actual)
{try.#Failure error}
false)]
[n.= n.binary "11,00,10,01"]
[i.= i.binary "+11,00,10,01"]
[i.= i.binary "-11,00,10,01"]
[r.= r.binary ".11,00,10,01"]
[f.= f.binary "+11,00.10,01"]
[f.= f.binary "-11,00.10,01"]
)))))
(_.coverage [/.oct]
(`` (and (~~ (template [<=> <codec> <number>]
[(case (at <codec> decoded (..clean_commas <number>))
{try.#Success actual}
(<=> (/.oct <number>) actual)
{try.#Failure error}
false)]
[n.= n.octal "615,243"]
[i.= i.octal "+615,243"]
[i.= i.octal "-615,243"]
[r.= r.octal ".615,243"]
[f.= f.octal "+61,52.43"]
[f.= f.octal "-61,52.43"]
)))))
(_.coverage [/.hex]
(`` (and (~~ (template [<=> <codec> <number>]
[(case (at <codec> decoded (..clean_commas <number>))
{try.#Success actual}
(<=> (/.hex <number>) actual)
{try.#Failure error}
false)]
[n.= n.hex "dead,BEEF"]
[i.= i.hex "+dead,BEEF"]
[i.= i.hex "-dead,BEEF"]
[r.= r.hex ".dead,BEEF"]
[f.= f.hex "+dead,BE.EF"]
[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
)))
|