dunlin

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

macros.fnl (642B)


      1 (fn trace [x]
      2   `(do
      3      (print :trace ,(view x) (view ,x))
      4      ,x))
      5 
      6 (fn expect [assertion]
      7   (let [msg (.. "expectation failed: " (view assertion))]
      8     `(when (not ,assertion)
      9        (assert false ,msg))))
     10 
     11 (fn expect= [actual expected]
     12   `(let [view# (. (require :fennel) :view)
     13          ve# (view# ,expected)
     14          va# (view# ,actual)]
     15      (when (not (= ve# va#))
     16        (assert false
     17                (.. "\nexpected " ve# "\ngot " va#)
     18                ))))
     19 
     20 (fn describe [thing & body]
     21   (when _G.RUNNING_TESTS
     22     `(do (print "# " ,(view thing))
     23          ,(unpack body))))
     24 
     25 { : trace : expect : expect= : describe }
     26 
     27 ;; NO-TESTING