Library

std/testing

Runtime assertions for @test functions.

1 file lib/std/testing/testing.vader 9 exports

Each helper panics via the std/abort host intrinsic panic on failure, with a self-explanatory message that names the expected/actual values. The vader test runner intercepts those panics and reports the offending arm as a failed test.

Composition: every helper builds on panic (the only primitive that actually traps). @assert is a comptime-only top-level decorator and is not what these run-time assertions hook into.

Functions

assert :: fn(cond: bool, msg: string) -> void

Plain boolean assertion. assert(false, "...") traps with msg.

Parameters

condbool No description.
msgstring No description.
fail :: fn(msg: string) -> void

Fail unconditionally with msg. Useful for unreachable-arm guards inside tests (match x { is Foo -> ok() _ -> fail("x was not Foo") }).

Parameters

msgstring No description.
assert_eq :: fn<T: Display & Equals>(actual: T, expected: T) -> void

Assert actual == expected. Failure message includes both values.

Parameters

actualT No description.
expectedT No description.
assert_ne :: fn<T: Display & Equals>(actual: T, unexpected: T) -> void

Assert actual != unexpected. Failure message names the value.

Parameters

actualT No description.
unexpectedT No description.
assert_lt :: fn<T: Display & Comparable>(actual: T, bound: T) -> void

Assert actual < bound.

Parameters

actualT No description.
boundT No description.
assert_lte :: fn<T: Display & Comparable>(actual: T, bound: T) -> void

Assert actual <= bound.

Parameters

actualT No description.
boundT No description.
assert_gt :: fn<T: Display & Comparable>(actual: T, bound: T) -> void

Assert actual > bound.

Parameters

actualT No description.
boundT No description.
assert_gte :: fn<T: Display & Comparable>(actual: T, bound: T) -> void

Assert actual >= bound.

Parameters

actualT No description.
boundT No description.
assert_close :: fn(actual: f64, expected: f64, eps: f64) -> void

Assert |actual - expected| <= eps. Float-friendly equality.

Parameters

actualf64 No description.
expectedf64 No description.
epsf64 No description.
Written by vader doc. Icons: Codicons, CC BY 4.0. Fonts: Atkinson Hyperlegible, JetBrains Mono, OFL.