From 7c07d6e6ececbf73e18a639e00b3690d4827e12a Mon Sep 17 00:00:00 2001 From: dozens Date: Wed, 29 May 2024 19:26:41 -0600 Subject: tests --- lib/either.test.fnl | 81 +++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 40 deletions(-) (limited to 'lib/either.test.fnl') diff --git a/lib/either.test.fnl b/lib/either.test.fnl index fc819dc..8ae0c08 100644 --- a/lib/either.test.fnl +++ b/lib/either.test.fnl @@ -1,40 +1,41 @@ -(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")) - - - -) +(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)))) -- cgit 1.4.1-2-gfad0