Skip to main content

Module test

Module test 

Source
Expand description

Test framework for Windjammer

Provides test primitives similar to Rust’s test framework

Functions§

assert
Assert that a condition is true
assert_approx
Assert that two floating point values are approximately equal
assert_approx_f32
Assert that two f32 values are approximately equal
assert_contains
Assert that a collection contains an item
assert_deep_eq
Assert that two values are deeply equal (same as assert_eq, but explicit name)
assert_empty
Assert that a collection is empty
assert_ends_with
Assert that a string ends with a suffix
assert_eq
Assert that two values are equal
assert_gt
Assert that a value is greater than another
assert_gte
Assert that a value is greater than or equal to another
assert_in_range
Assert that a value is in a range
assert_is_err
Assert that a Result is Err
assert_is_none
Assert that an Option is None
assert_is_ok
Assert that a Result is Ok
assert_is_some
Assert that an Option is Some
assert_length
Assert that a collection has a specific length
assert_lt
Assert that a value is less than another
assert_lte
Assert that a value is less than or equal to another
assert_ne
Assert that two values are not equal
assert_not_empty
Assert that a collection is not empty
assert_panics
Assert that a closure panics
assert_panics_with
Assert that a closure panics with a specific message
assert_result_err
Assert that a Result matches Err pattern
assert_result_ok
Assert that a Result matches a pattern (Ok or Err) This is a simplified version - full pattern matching requires compiler support
assert_starts_with
Assert that a string starts with a prefix
assert_str_contains
Assert that a string contains a substring
current_test
Get the current test name
ensures
Check a postcondition (used by @ensures decorator) Asserts that a condition is true after a function executes
fail
Mark a test as failed
failed_count
Get the number of tests failed
invariant
Check an invariant (used by @invariant decorator) Asserts that a condition remains true throughout execution
pass
Mark a test as passed
passed_count
Get the number of tests passed
requires
Check a precondition (used by @requires decorator) Asserts that a condition is true before a function executes
reset
Reset test counters (for test isolation)
set_current_test
Set the current test name