blob: f2643a3b7e4b038e367016b211112b4cf310e978 (
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>)]
["." io]
["." maybe ("#\." functor)]
["." try]
["." exception]
[parser
[environment (#+ Environment)]]]
[data
["." text ("#\." equivalence)]
[collection
["." dictionary]
["." list]]]
[math
["." random (#+ Random)]
[number
["n" nat]]]]]
[\\library
["." /
[//
[file (#+ Path)]]]]
[\\specification
["$." /]])
(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 (\ ! map (|>> (n.% 10) inc) 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.get key)
(maybe\map (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)))))
))))
|