Assert Expression

assert-expression ::= 'assert' expression

Evaluates expression (the condition). If the result does not test as truthy, a panic occurs. An assert expression is always executed; it is not conditional on build flags or similar.

An assert expression is typically used in a test declaration to verify the outcome of a unit test, but it can also be used in regular code. The runtime system is allowed to optimize with the assumption that condition holds after the assert expression.

The result of an assert expression is the value of the condition.

Last updated

Copyright © Vezel Contributors