ofLazy

infix fun <Value> Expect.Companion.ofLazy(provider: () -> Value): Expect<Value>(source)

Creates an Expect assertion using a lazily-evaluated value provider function.

The value is obtained by calling the provider function only when Expect.exposeValue is first called. The value is cached after the first evaluation.

Return

An Expect instance wrapping the lazily-provided value.

Parameters

provider

A function that provides the value to assert on. Called at most once.

Type Parameters

Value

The type of the value being asserted on.


inline fun <Value> Expect.Companion.ofLazy(noinline provider: () -> Value, block: Expect<Value>.() -> Unit)(source)

Creates an Expect assertion using a lazily-evaluated value provider function and executes the assertion block on it.

The value is obtained lazily, and the block is called exactly once with the value as the receiver.

Parameters

provider

A function that provides the value to assert on. Called at most once.

block

The assertion block to execute with the lazily-provided value as the receiver.

Type Parameters

Value

The type of the value being asserted on.