test

Lightweight test registration, assertions, and result reporting.

Import

import test

Functions

test.assert(cond: bool)

Assert that cond is truthy, failing the current test if not.

test.assert_eq(a: any, b: any)

Assert structural equality between a and b.

test.assert_ne(a: any, b: any)

Assert that a and b are not equal.

test.run(name: str, fn: () -> void)

Register a named test case. The function runs immediately in script mode or when xs test collects the file.

test.summary()

Print a summary of passed/failed tests and exit with code 1 if any failed.

Examples

scratch.xs