Testing module

require

procedureextensionsince 0.28.0Source

The require forms check the same way and, when the check fails, return from the procedure they are written in (which must return nothing). Use them when the rest of the test needs the check to hold. In a helper that returns a value, use the expect form instead.

Example
items: [..] int;
array_add(*items, 1);
require(items.count == 1);
expect_equal(items[0], 1);
require :: (condition: bool, message := "", loc := #caller_location)

The require forms check the same way and, when the check fails, return from the procedure they are written in (which must return nothing). Use them when the rest of the test needs the check to hold. In a helper that returns a value, use the expect form instead.

Parameters

condition: bool
what must be true.
message := ""
what to report instead of the default.
loc := #caller_location
where the check is written, shown when it fails. Leave the default.
Example
items: [..] int;
array_add(*items, 1);
require(items.count == 1);
expect_equal(items[0], 1);

See also