Pyro

A dynamically-typed, garbage-collected scripting language.

Version 0.19.2

Assertions


An assert statement panics if its operand expression evaluates as falsey, e.g.

assert 1 + 1 == 2; # okay
assert 1 + 1 == 3; # panics

(In Pyro, the values false, null, and err are falsey; all other values are truthy.)

The syntax of an assert statement is:

assert <expression> [, <error-message>] ;

Optionally, you can specify an error message in case the assertion fails, e.g.

let result = get_result();
assert result == 123, "unexpected result: ${result}";

The error message can be an arbitrary expression — if its value isn't a string, it will be automatically stringified.