assert

Executes the given assertion checker and consumes its result.

The checker function should return an AssertionScope.Assertion describing the assertion result. If the checker throws an exception, it is wrapped in an AssertionError and rethrown. Otherwise, the resulting assertion is passed to consumeAssertion.

Receiver

The assertion scope that will consume the assertion result.

Parameters

checker

A function that performs an assertion check and returns an AssertionScope.Assertion. Called exactly once.


@JvmName(name = "assertContextual")
context(assertionScope: AssertionScope)
inline fun assert(checker: () -> AssertionScope.Assertion)(source)

Executes the given assertion checker within the current assertion scope.

This contextual version uses the assertionScope from the surrounding context. The checker function should return an AssertionScope.Assertion describing the assertion result.

Context Parameters

assertionScope

The assertion scope that will consume the assertion result.

Parameters

checker

A function that performs an assertion check and returns an AssertionScope.Assertion. Called exactly once.

See also


context(assertionScope: AssertionScope)
inline fun <Value> Expect<Value>.assert(checker: (Value) -> AssertionScope.Assertion)(source)

Executes the given assertion checker on the value exposed by this Expect instance.

The checker function receives the exposed value and should return an AssertionScope.Assertion describing the assertion result. The assertion is executed within the current assertion scope.

Receiver

The Expect instance whose value will be asserted on.

Context Parameters

assertionScope

The assertion scope that will consume the assertion result.

Parameters

checker

A function that receives the exposed value and returns an AssertionScope.Assertion. Called exactly once.

Type Parameters

Value

The type of the value being asserted on.