Basic module

assert

procedure2 overloadsSource

Stops the program with a message when arg is false. message can hold % markers filled from args, the same way print does. The failure goes through context.assertion_failed, which prints the location and a stack trace and exits by default.

assert :: (arg: bool, message := "", args: ..Any, loc := #caller_location)

Asserts are compiled out when Basic is imported with ENABLE_ASSERT = false, and the arguments are not evaluated then.

Parameters

arg: bool
message := ""
args: ..Any
loc := #caller_location
Example↗
count := 3;
assert(count > 0, "count must be positive, got %", count);

This one is only checked to compile, not run.

assert :: (arg: bool, message := "", args: ..Any, loc := #caller_location)

Parameters

arg: bool
message := ""
args: ..Any
loc := #caller_location

See also