assert_fails
Asserts a function fails; i.e. throws an exception.
Example
Application code
// This will throw a exception.
function bad(): integer {
return [0][1];
}
Content copied to clipboard
Test code
// This test will pass.
function test_bad() {
rell.test.assert_fails(bad(*));
}
Content copied to clipboard
Alias
Alias target
Since
0.11.0
Parameters
fn
the function value to invoke
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];
}
Content copied to clipboard
Test code
// This test will pass.
function test_bad() {
rell.test.assert_fails("out of bounds", bad(*));
}
Content copied to clipboard
Alias
Alias target
Since
0.11.0
Parameters
expected_message
the expected substring of the error message
fn
the function value to invoke