Developer Tools

vassert

Say what must be true, and let your program hold itself to it.

Released v1.0.0 · 2026-09-28
Import
use "stdlib/assert.ven"

Assertions that state what must be true, and report the expected and actual values when one fails.

vassert.ven
equal(2 + 2, 4, "math check")
print "the sum holds"

:: equal(2 + 2, 5, "math check") raises "math check: expected 5 but got 4"
Reference (9 functions)

API reference

equal(actual, expected, message)

Asserts that actual equals expected, raising a descriptive error otherwise.

equal(2 + 2, 5, "math check")
:: raises "math check: expected 5 but got 4"

not_equal(actual, expected, message)

Asserts that actual does not equal expected, raising a descriptive error otherwise.

not_equal(3, 3, "")
:: raises "expected a value different from 3"

truthy(value, message)

Asserts that value is truthy, raising a descriptive error otherwise.

truthy(0, "")
:: raises "expected a truthy value but got 0"

falsy(value, message)

Asserts that value is falsy, raising a descriptive error otherwise.

falsy(1, "")
:: raises "expected a falsy value but got 1"

raises(work_fn, expected_message_substring)

Asserts that calling work_fn raises an error whose text contains expected_message_substring.

make boom()
    raise "disk is full"
raises(boom, "disk")
:: passes silently

approximately_equal(actual, expected, tolerance)

Asserts that actual is within tolerance of expected, raising a descriptive error otherwise.

approximately_equal(1.0, 1.5, 0.1)
:: raises "expected 1.0 to be within 0.1 of 1.5 but the difference was 0.5"

contains_item(container, item)

Asserts that item is found inside container, raising a descriptive error otherwise.

contains_item([1, 2, 3], 9)
:: raises "9 was not found in [1, 2, 3]"

list_equal_unordered(actual, expected)

Asserts that actual and expected hold the same elements as multisets, raising a descriptive error otherwise.

list_equal_unordered([1, 2, 3], [3, 2, 1])
:: passes silently

fail(message)

Unconditionally raises message as an error.

fail("custom failure")
:: raises "custom failure"

Get notified when vassert changes

Get notified about

New versions and security advisories.

New and updated packages, once a day.

News on the math model built in Venutian.