Standardbibliothek
Antra::Test
import Antra::TestMinimal test helpers for Antra library tests.
This package keeps the test surface intentionally small: named test cases, a few basic assertions and a tiny TAP-like runner with a failing exit path.
Funktionen#
fn assert_contains(haystack, needle)
fn assert_contains(haystack, needle, message)Asserts that haystack contains needle as a substring.
Pass a third string argument to override the default failure message.
fn assert_eq(actual, expected)
fn assert_eq(actual, expected, message)Asserts deep equality using Antra's == semantics.
Pass a third string argument to override the default failure message.
fn assert_error(on_use expr, needle)
fn assert_error(on_use expr, needle, message)Asserts that f() throws and that the error message contains needle.
Pass a third string argument to override the default failure message.
fn assert_true(value)
fn assert_true(value, message)Asserts that value is truthy.
Pass a second string argument to override the default failure message.
fn case(name, run)Wraps a named zero-argument test function into a runnable tagged value.
The returned shape is %TestCase[name, run].
fn run_test(subject)
fn run_test(subject, opts)Discovers zero-argument test functions on one package or an array of
packages and runs them via run_tests(...).
Discovery rules in v1:
- every exported function whose name ends with
_testis collected - any exported function with
@Test(...)is collected even without the suffix @Test("...")overrides the displayed test name@TestSuite(...)on a package may contribute suite metadata and a default group for discovered tests
fn run_tests(cases, [colorize: = false, group: = undef, ..])Runs all test cases, prints a tiny TAP-like report and throws on failure.
Optional settings may be passed as a keyword array.
cases must be an array of values returned by case(...), i.e.
%TestCase[name, run] tagged values.
Supported options:
colorize: truecolors passed tests green, failed tests red, and the final summary in a more readable way while preserving theok/not okTAP-like line prefix.group: :nameruns only discovered tests whose effective group matches.
