blob: 430217ed49cd8c522513ac36b8c9396ab856d1cd (
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
|
(.require
[library
[lux (.except)
[abstract
[monad (.only do)]
[\\specification
["$[0]" hash]]
["[0]" codec
["[1]T" \\test]]
["[0]" equivalence
["[1]T" \\test]]
["[0]" order
["[1]T" \\test]]]
[data
["[0]" text]]
[math
["[0]" random (.only Random)]
[number
["n" nat]]]
[meta
[macro
["^" pattern]]]
[test
["_" property (.only Test)]]]]
[\\library
["[0]" /]])
(def .public (random module_size short_size)
(-> Nat Nat (Random Symbol))
(random.and (random.alphabetic module_size)
(random.alphabetic short_size)))
(def .public test
Test
(<| (_.covering /._)
(do [! random.monad]
[... First Symbol
sizeM1 (|> random.nat (of ! each (n.% 100)))
sizeS1 (|> random.nat (of ! each (|>> (n.% 100) (n.max 1))))
(^.let symbol1 [module1 short1]) (..random sizeM1 sizeS1)
... Second Symbol
sizeM2 (|> random.nat (of ! each (n.% 100)))
sizeS2 (|> random.nat (of ! each (|>> (n.% 100) (n.max 1))))
(^.let symbol2 [module2 short2]) (..random sizeM2 sizeS2)]
(_.for [.Symbol]
(all _.and
(_.for [/.equivalence]
(equivalenceT.spec /.equivalence (..random sizeM1 sizeS1)))
(_.for [/.hash]
(|> (random.ascii 1)
(of ! each (|>> [""]))
($hash.spec /.hash)))
(_.for [/.order]
(orderT.spec /.order (..random sizeM1 sizeS1)))
(_.for [/.codec]
(_.and (codecT.spec /.equivalence /.codec (..random sizeM1 sizeS1))
(_.test "Encoding a symbol without a module component results in text equal to the short of the symbol."
(if (text.empty? module1)
(same? short1 (of /.codec encoded symbol1))
true))))
(_.coverage [/.separator]
(let [it (of /.codec encoded symbol1)]
(if (text.empty? module1)
(same? short1 it)
(text.contains? /.separator it))))
(_.coverage [/.module /.short]
(and (same? module1 (/.module symbol1))
(same? short1 (/.short symbol1))))
(_.for [.symbol]
(let [(open "/#[0]") /.equivalence]
(all _.and
(_.test "Can obtain Symbol from a symbol."
(and (/#= [.prelude "yolo"] (.symbol .yolo))
(/#= ["test/lux/meta/symbol" "yolo"] (.symbol ..yolo))
(/#= ["" "yolo"] (.symbol yolo))
(/#= ["library/lux/test" "yolo"] (.symbol library/lux/test.yolo)))))))
)))))
|