blob: 8ae0c08de0076dbd213981592fc7f94f0c2f1e51 (
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
|
(let [{: pprint} (require :lib.tableprint)
{: describe :end test-end} (require :lib.test)
{: Either : Left : Right } (require :lib.either)]
(describe "Either" (fn [t]
(t {:given "a new either"
:should "set its value correctly"
:expected :poop
:actual (. (Either:new :poop) :value)
})
(t
(let [r (Right:new "rain")
map (r:map #(.. "b" $1))
expected :brain
actual (. map :value)]
{:given "a Right of some value"
:should "map"
expected
actual
}))
(t
(let [ l (Left:new "rain")
map (l:map #(.. "b" $1))
expected :rain
actual (. map :value)
]
{:given "a Left of some value"
:should "not map"
expected
actual
}))
(t
(let [ e (Either.of "rank")
map (e:map #(.. "f" $1))
expected :frank
actual (. map :value) ]
{:given "Either.of"
:should "map"
expected
actual
}))
(test-end))))
|