Testing module

expect

procedureextensionsince 0.28.0Source

Checks condition, reports a failure at the caller's line and returns whether it held. The other expect* checks work the same way; jacket test shows the line's source next to the message.

Example
expect(1 + 1 == 2);
expect(1 + 1 == 2, "the arithmetic is off"); // the message replaces the default one
expect :: (condition: bool, message := "", loc := #caller_location) -> bool

Checks condition, reports a failure at the caller's line and returns whether it held. The other expect* checks work the same way; jacket test shows the line's source next to the message.

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.

Returns

bool
Example
expect(1 + 1 == 2);
expect(1 + 1 == 2, "the arithmetic is off"); // the message replaces the default one

See also