blob: 31bf105cd35cbbf18ff2665b597c76ab6c9c017a (
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
|
(.module:
[lux #*
[control
["M" monad (#+ Monad do)]
comonad]
[data
["&" identity]
[text ("text/." monoid equivalence)]]]
lux/test)
(context: "Identity"
(let [(^open "&/.") &.apply
(^open "&/.") &.monad
(^open "&/.") &.comonad]
($_ seq
(test "Functor does not affect values."
(text/= "yololol" (&/map (text/compose "yolo") "lol")))
(test "Apply does not affect values."
(and (text/= "yolo" (&/wrap "yolo"))
(text/= "yololol" (&/apply (&/wrap (text/compose "yolo")) (&/wrap "lol")))))
(test "Monad does not affect values."
(text/= "yololol" (do &.monad
[f (wrap text/compose)
a (wrap "yolo")
b (wrap "lol")]
(wrap (f a b)))))
(test "CoMonad does not affect values."
(and (text/= "yololol" (&/unwrap "yololol"))
(text/= "yololol" (be &.comonad
[f text/compose
a "yolo"
b "lol"]
(f a b)))))
)))
|