Module devel.ensure
Functions for writing tests.
These functions write messages to stdout, so it’s natural
to run tests using mcscript
.
Example:
local ensure = devel.ensure ensure(4 > 3, "Basic math") ensure.equal(utils.text.parse_size("4KB"), 4000, "parse_size()")
Functions
does_not_throw(f, msg) | Tests that some code does not throw exception. |
equal(a, b, msg) | Tests for equality. |
not_equal(a, b, msg) | Tests for inequality. |
ok(cond, msg) | Tests a condition. |
throws(f, needle, msg) | Tests that some code throws exception. |
Functions
- does_not_throw(f, msg)
- Tests that some code does not throw exception.
- equal(a, b, msg)
- Tests for equality.
- not_equal(a, b, msg)
- Tests for inequality.
- ok(cond, msg)
-
Tests a condition.
local ensure = devel.ensure ensure.ok(4 > 3, "Basic math")
- throws(f, needle, msg)
-
Tests that some code throws exception.
local ensure = devel.ensure ensure.throws(function() -- A pattern cannot start with a star! regex.compile "*" end, nil, "Invalid regex pattern throws error")
The needle argument, if provided, is a sub-string to ensure appears in the exception message.