Companion

Companion object for the Expect interface, providing factory methods for creating assertions.

Functions

Link copied to clipboard
context(assertionScope: AssertionScope)
inline fun Expect.Companion.notToThrow(crossinline block: () -> Unit)

Asserts that the given block does not throw any exception.

context(assertionScope: AssertionScope)
inline fun <Result> Expect.Companion.notToThrow(crossinline block: () -> Result, checker: Expect<Result>.() -> Unit)

Asserts that the given block does not throw any exception, and if it succeeds, asserts on the result using the provided checker.

Link copied to clipboard
infix fun <Value> Expect.Companion.of(value: Value): Expect<Value>

Creates an Expect assertion for the given value.

inline fun <Value> Expect.Companion.of(value: Value, block: Expect<Value>.() -> Unit)

Creates an Expect assertion for the given value and executes the assertion block on it.

Link copied to clipboard
infix fun <Value> Expect.Companion.ofLazy(provider: () -> Value): Expect<Value>

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

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

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

Link copied to clipboard
context(assertionScope: AssertionScope)
inline fun Expect.Companion.toThrow(crossinline block: () -> Unit)

Asserts that the given block throws an exception.

@JvmName(name = "orThrowCheckingType")
context(assertionScope: AssertionScope)
inline fun <ThrowableType : Throwable> Expect.Companion.toThrow(crossinline block: () -> Unit, checker: Expect<ThrowableType>.() -> Unit)

Asserts that the given block throws an exception of the specified type ThrowableType, and if it does, asserts on the thrown exception using the provided checker.

context(assertionScope: AssertionScope)
inline fun Expect.Companion.toThrow(crossinline block: () -> Unit, checker: Expect<Throwable>.() -> Unit)

Asserts that the given block throws an exception, and if it does, asserts on the thrown exception using the provided checker.

Link copied to clipboard
infix fun <Value> Expect.Companion.using(provider: () -> Value): Expect<Value>

Creates an Expect assertion using a value provider function.

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

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