blob: f98fc6a174448673f129b344b1b6107c78b2589f (
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
|
(.module:
[lux #*
["_" test (#+ Test)]
[abstract
[monad (#+ do)]]
[control
["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
[number
["n" nat]
["i" int]]
[collection
["." list]]]]
{1
["." /]}
{[1 #spec]
["$." /]})
(exception: dead)
(def: (simulation [environment command arguments])
(-> [/.Environment /.Command (List /.Argument)]
(/.Simulation Bit))
(structure
(def: (on-read dead?)
(if dead?
(exception.throw ..dead [])
(do try.monad
[to-echo (try.from-maybe (list.head arguments))]
(wrap [dead? to-echo]))))
(def: (on-error dead?)
(if dead?
(exception.throw ..dead [])
(exception.return [dead? ""])))
(def: (on-write message dead?)
(if dead?
(exception.throw ..dead [])
(#try.Success dead?)))
(def: (on-destroy dead?)
(if dead?
(exception.throw ..dead [])
(#try.Success true)))
(def: (on-await dead?)
(if dead?
(exception.throw ..dead [])
(#try.Success [true /.normal])))))
(def: #export test
Test
(<| (_.covering /._)
(_.with-cover [/.mock /.Simulation]
($/.spec (/.mock (|>> ..simulation #try.Success)
false)))))
|