assert_fails

(alias) function <T> assert_fails(fn: () -> T): rell.test.failure

Asserts 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(*));
}

Alias

Since

0.11.0

Parameters

fn

the function value to invoke


(alias) function <T> assert_fails(expected_message: text, fn: () -> T): rell.test.failure

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(*));
}

Alias

Since

0.11.0

Parameters

expected_message

the expected substring of the error message

fn

the function value to invoke