inline test spec
alidcast opened this issue · 0 comments
alidcast commented
would there be a way to write inline tests with ghostwheel?
as an example, there's a clojureverse post of someone using defn-spec for inline tests; here's the code snippet:
(defn abs
"The absolute value of a number."
{:test (fn []
(is (= (Math/abs 5) 5))
(is (= (Math/abs -2) 2))
(is (= (Math/abs 0) 0)))}
[x]
{:pre [(number? x)]}
(if (pos? x)
x
(- x)))
(though I'd personally prefer if the test spec came after the function body, rather than before it, if possible)