dunlin/macros.fnl
2024-09-10 22:44:21 +01:00

28 lines
642 B
Fennel

(fn trace [x]
`(do
(print :trace ,(view x) (view ,x))
,x))
(fn expect [assertion]
(let [msg (.. "expectation failed: " (view assertion))]
`(when (not ,assertion)
(assert false ,msg))))
(fn expect= [actual expected]
`(let [view# (. (require :fennel) :view)
ve# (view# ,expected)
va# (view# ,actual)]
(when (not (= ve# va#))
(assert false
(.. "\nexpected " ve# "\ngot " va#)
))))
(fn describe [thing & body]
(when _G.RUNNING_TESTS
`(do (print "# " ,(view thing))
,(unpack body))))
{ : trace : expect : expect= : describe }
;; NO-TESTING