test
Checks for your own tests. Put them in files ending in _test.tb and run tb test.
import test
Example
import test
test.equal(1 + 1, 2, "maths still works")
test.true("tb".upper() == "TB", "upper() works")
test.raises(fn() { throw "boom" })
say(test.results())
Functions
equal(actual, expected, message?)
returns boolCheck that two values are the same (lists and maps are compared item by item).
not_equal(a, b, message?)
returns boolCheck that two values are different.
true(value, message?)
returns boolCheck that a value is true (anything but false and nil).
false(value, message?)
returns boolCheck that a value is false or nil.
raises(fn, part?)
returns map or nilCheck that calling fn() stops with an error (whose message contains part, if given). Gives back the error map.
case(name, fn)
Run one named test. If fn stops with an error, that counts as a failure and the other cases still run.
results()
returns mapHow many checks passed and failed so far: {"passed", "failed"}.