FUNCTION
assert_fails
function assert_fails<T>(fn: () -> T): failureAsserts a function fails; i.e. throws an exception.
Example
Application code
// This will throw a exception.
function bad(): integer {
return [0][1];
}
Test code
// This test will pass.
function test_bad() {
rell.test.assert_fails(bad(*));
// or inline:
rell.test.assert_fails(() -> [0][1]);
}
Parameters
- fn — the function value to invoke
Since
0.11.0
Asserts a function fails; i.e. throws an exception; with a given exception message.
Verifies that the given exception message is a substring of the exception thrown by the given function (if thrown).
Example
Application code
// This will throw a exception.
function bad(): integer {
return [0][1];
}
Test code
// This test will pass.
function test_bad() {
rell.test.assert_fails("out of bounds", bad(*));
// or inline:
rell.test.assert_fails("out of bounds", () -> [0][1]);
}
Parameters
- expected_message — the expected substring of the error message
- fn — the function value to invoke
Since
0.11.0
© 2026 Chromia