busted
busted copied to clipboard
Implement loader for Fennel
Closes #738
Tests can be written in Fennel if fennel
is among the loaders. Currently the traceback is wrong for failures and pending tests, but it is wrong for tests written in Moonscript as well, so this seems to be a general problem with busted.
It would have been cool if we could make it
, describe
and so on into macros to not have to manually wrap the test body inside a thunk every time.
;; With macro
(it "Adds two numbers"
(assert.are.equal 5 (+ 2 3)))
;; Without macro
(it "Adds two numbers"
(fn []
(assert.are.equal 5 (+ 2 3))))
This macro can accomplish it when added to the beginning of a test:
(macro it [description & body]
`(let [fenv# (or (and getfenv (getfenv)) _ENV)]
((. fenv# :it) ,description
(fn [] ,(unpack body)))))
However, the source map produces rather weird mappings from Lua to Fennel (it maps the assertion to the body of the macro definition), so for now I won't pursue this.