mirror of
https://github.com/correl/calrissian.git
synced 2024-11-23 19:19:57 +00:00
33 lines
929 B
Text
33 lines
929 B
Text
(defmodule unit-calrissian-error-monad-tests
|
|
(behaviour ltest-unit)
|
|
(export all))
|
|
|
|
(include-lib "ltest/include/ltest-macros.lfe")
|
|
(include-lib "calrissian/include/monads.lfe")
|
|
(include-lib "calrissian/include/monad-tests.lfe")
|
|
|
|
(test-monad (monad 'error))
|
|
|
|
(deftest return-ok
|
|
(is-equal 'ok
|
|
(return (monad 'error) 'ok)))
|
|
|
|
(deftest return-value
|
|
(is-equal #(ok 123)
|
|
(return (monad 'error) 123)))
|
|
|
|
(deftest fail-with-reason
|
|
(is-equal #(error reason)
|
|
(fail (monad 'error) 'reason)))
|
|
|
|
(deftest fail-short-circuits-value
|
|
(is-equal (fail (monad 'error) 'something-bad)
|
|
(>> (monad 'error)
|
|
(fail (monad 'error) 'something-bad)
|
|
(return (monad 'error) 123))))
|
|
|
|
(deftest fail-short-circuits-error
|
|
(is-equal #(error something-bad)
|
|
(>> (monad 'error)
|
|
(fail (monad 'error) 'something-bad)
|
|
(throw 'error))))
|