53 lines
1.1 KiB
Plaintext
53 lines
1.1 KiB
Plaintext
|
(local {: pprint} (require :lib.tableprint))
|
||
|
(local {: equal} (require :lib.equal))
|
||
|
|
||
|
(var plan 0)
|
||
|
|
||
|
(fn once [funky]
|
||
|
(var bang false)
|
||
|
(fn [...]
|
||
|
(if (not bang)
|
||
|
(do
|
||
|
(funky ...)
|
||
|
(set bang true)))))
|
||
|
|
||
|
(fn test [obj]
|
||
|
(let [{: given : should : actual : expected} obj
|
||
|
ok (if (equal actual expected) :ok "not ok")
|
||
|
description (.. "Given " given " should " should)
|
||
|
]
|
||
|
(set plan (+ 1 plan))
|
||
|
(print (.. ok " " plan " - " description))
|
||
|
(if (= "not ok" ok)
|
||
|
(do
|
||
|
(print " ---")
|
||
|
(if (= :table (type expected))
|
||
|
(do
|
||
|
(print (.. " expected: " ))
|
||
|
(pprint expected))
|
||
|
(print (.. " expected: " (tostring expected))))
|
||
|
(if (= :table (type actual))
|
||
|
(do
|
||
|
(print (.. " actual: " ))
|
||
|
(pprint actual))
|
||
|
(print (.. " actual: " (tostring actual))))
|
||
|
(print " ...")
|
||
|
)
|
||
|
)
|
||
|
))
|
||
|
|
||
|
(local print-header (once (fn [] (print "TAP version 14"))))
|
||
|
|
||
|
(fn desc [str cb]
|
||
|
(print-header)
|
||
|
(print (.. "#" str))
|
||
|
(cb test)
|
||
|
)
|
||
|
(fn end []
|
||
|
(print (.. 1 ".." plan))
|
||
|
)
|
||
|
|
||
|
|
||
|
{:describe desc
|
||
|
: end}
|