2024-06-20 15:17:06 +00:00
|
|
|
(let [{:print pprint} (require :lib.table)
|
|
|
|
{: describe : test-end} (require :lib.test)
|
2024-05-30 01:26:41 +00:00
|
|
|
{: Either : Left : Right } (require :lib.either)]
|
2024-06-20 15:17:06 +00:00
|
|
|
(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))))
|