Skip to content

std/assert

Runtime assertions.

#include "std/assert.gof"

runtime_assert

pub func void runtime_assert[int a, int b, *string sv]

Checks that a == b. If not, prints "runtime_assert: Assertion failed, " followed by sv to STD_ERR, then calls abort.

1 1 "values must be equal" call runtime_assert    // passes
1 2 "values must be equal" call runtime_assert    // aborts

assert

Alias for runtime_assert:

#define assert runtime_assert
1 1 "values must be equal" call assert

Integers only

runtime_assert compares int values. It cannot compare other types (generics are not supported yet).

Aborts the process

On failure, runtime_assert calls abort. It does not throw or return.