summaryrefslogtreecommitdiff
path: root/lib/either.test.fnl
diff options
context:
space:
mode:
authordozens2024-05-28 15:04:00 -0600
committerdozens2024-05-28 15:04:00 -0600
commitf265d24c0cacb92c7f7db19f364a155d87938184 (patch)
treea6e3ce61dee9020b79c8f2d8e3c91b51bc29e959 /lib/either.test.fnl
inits
Diffstat (limited to 'lib/either.test.fnl')
-rw-r--r--lib/either.test.fnl40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/either.test.fnl b/lib/either.test.fnl
new file mode 100644
index 0000000..fc819dc
--- /dev/null
+++ b/lib/either.test.fnl
@@ -0,0 +1,40 @@
+(local {: pprint} (require :lib.tableprint))
+
+(let [{
+ : Either
+ : Left
+ : Right
+ } (require :lib.either)]
+
+ ;; either
+ ;(print "Either Inspection")
+ ;(pprint Either)
+
+ ;; you can set and get values
+ (let [ v :poop x (Either:new v)]
+ (assert (= v x.value) (.. "The value is " v)))
+
+ (let [r (Right:new "rain")
+ map (r:map #(.. "b" $1))
+ expected :brain
+ actual (. map :value)
+ ]
+ (assert (= expected actual) "You can map a Right value"))
+
+ (let [l (Left:new "rain")
+ map (l:map #(.. "b" $1))
+ expected :rain
+ actual (. map :value)
+ ]
+ (assert (= expected actual) "You can NOT map a Left value"))
+
+ (let [e (Either.of "rank")
+ map (e:map #(.. "f" $1))
+ expected :frank
+ actual (. map :value)
+ ]
+ (assert (= expected actual) "You can map a Either.of"))
+
+
+
+)