Skip to content

Assert

1 min read

Import: import system.testing;

Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.

Assert

Assertion helpers for system.testing. On failure, prints a message and exits the process with a non-zero status (no exceptions/panics — assertions are meant to run in ordinary scripts). Exit-based failures require a real process model (@native / @node); not available on @web.

public static class Assert

fail

Fails the current test run with message: prints it and terminates the process with a non-zero exit code. There is no exception mechanism to unwind through, so Assert.* failures are unrecoverable by design (matching System.panic).

public static fun fail(message: string): void

eq_async

Awaits actual and compares its value using the normal assertion diagnostics.

public static async fun eq_async<T>(actual: Future<T>, expected: T): void

ok_async

Awaits a fallible operation and returns its success value, reporting the error on failure.

public static async fun ok_async<T, E>(actual: Future<Result<T, E>>): T

eq

Asserts that actual == expected. String failures quote the expected and actual values.

public static fun eq<T>(actual: T, expected: T): void

ne

Asserts that actual != expected.

public static fun ne<T>(actual: T, expected: T): void

is_true

Asserts that value is true.

public static fun is_true(value: bool): void

is_false

Asserts that value is false.

public static fun is_false(value: bool): void

approx

Asserts that two doubles are within epsilon of each other.

public static fun approx(actual: double, expected: double, epsilon: double): void