March Docs

Test

Test module: lightweight assertion helpers for in-process testing.

Tests are plain March functions; a test passes if it returns without calling panic/fail. Use these helpers to make assertions.

Functions

fnassert_eqassert_eq(expected, actual, msg : String) : Unit#

Assert two values are structurally equal (generic).

Uses March's built-in structural equality (the `==` operator), so this
works on any types that aren't functions or opaque resources — ints,
strings, booleans, floats, tuples, records, ADT variants, lists, and
combinations of them.

On failure, both values are rendered via `to_string` (same form as
`inspect`/`debug`) and included in the panic message so failures
are easy to diagnose.

Example:
  Test.assert_eq((1, "a"), (1, "a"), "tuple equal")
  Test.assert_eq([1, 2, 3], [1, 2, 3], "list equal")
  Test.assert_eq(Some(42), Some(42), "option equal")
fnassert_eq_boolassert_eq_bool(a : Bool, b : Bool, msg : String) : Unit#

Assert two booleans are equal.

fnassert_eq_intassert_eq_int(a : Int, b : Int, msg : String) : Unit#

Assert two ints are equal.

fnassert_eq_strassert_eq_str(a : String, b : String, msg : String) : Unit#

Assert two strings are equal.

fnassert_errassert_err(res : Result(a, e), msg : String) : e#

Assert a Result is Err and return the error value.

fnassert_falseassert_false(cond : Bool, msg : String) : Unit#

Assert that cond is false; panic with msg if not.

fnassert_neassert_ne(left, right, msg : String) : Unit#

Assert two values are not structurally equal.

Counterpart to `assert_eq`; panics if the values compare equal via `==`.
Useful for checking that mutation/update paths actually changed something.
fnassert_noneassert_none(opt : Option(a), msg : String) : Unit#

Assert an Option is None.

fnassert_okassert_ok(res : Result(a, e), msg : String) : a#

Assert a Result is Ok and return the inner value.

fnassert_someassert_some(opt : Option(a), msg : String) : a#

Assert an Option is Some and return the inner value.

fnassert_trueassert_true(cond : Bool, msg : String) : Unit#

Assert that cond is true; panic with msg if not.

fnfailfail(msg : String) : Unit#

Fail immediately with a descriptive message.