blob: eafafecaa47f7daea40e158d3528f6caf2f98030 (
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
|
(.module:
[library
[lux "*"
["_" test {"+" [Test]}]
[abstract
[monad {"+" [do]}]]
[control
[pipe {"+" [case>]}]
["[0]" io]
["[0]" maybe ("[1]\[0]" functor)]
["[0]" try]
["[0]" exception]
[parser
[environment {"+" [Environment]}]]]
[data
["[0]" text ("[1]\[0]" equivalence)]
[collection
["[0]" dictionary]
["[0]" list]]]
[math
["[0]" random {"+" [Random]}]
[number
["n" nat]]]]]
[\\library
["[0]" /
[//
[file {"+" [Path]}]]]]
[\\specification
["$[0]" /]])
(def: (environment env_size)
(-> Nat (Random Environment))
(random.dictionary text.hash env_size
(random.ascii/alpha 5)
(random.ascii/alpha 5)))
(def: path
(Random Path)
(random.ascii/alpha 5))
(def: .public test
Test
(<| (_.covering /._)
(do [! random.monad]
[env_size (\ ! each (|>> (n.% 10) ++) random.nat)
environment (..environment env_size)
home ..path
directory ..path
unknown (random.ascii/alpha 1)]
($_ _.and
(_.for [/.mock /.async]
($/.spec (/.async (/.mock environment home directory))))
(_.cover [/.environment]
(let [program (/.mock environment home directory)]
(io.run!
(do io.monad
[actual (/.environment io.monad program)]
(in (and (n.= (dictionary.size environment)
(dictionary.size actual))
(|> actual
dictionary.entries
(list.every? (function (_ [key value])
(|> environment
(dictionary.value key)
(maybe\each (text\= value))
(maybe.else false)))))))))))
(_.cover [/.unknown_environment_variable]
(let [program (/.mock environment home directory)]
(|> unknown
(\ program variable)
io.run!
(case> (#try.Success _)
false
(#try.Failure error)
(exception.match? /.unknown_environment_variable error)))))
))))
|