assert

A keyword that can be used in Scripting, to test whether an expected condition holds.

Examples

This is an assertion that is satisfied:

a = 5*6
assert a = 30
writeInfoLine: a
=>
30

This is an assertion that is violated:

a = 5*6
assert a < 10
writeInfoLine: a

This three-line script stops at the second line with the error message “Assertion violated in line 2: a < 10”.

That is, because a is not less than 10 (it’s 30), the assertion is false, and the script stops, mentioning the line number as well as the text of the assertion (i.e. “a < 10”).

Links to this page


© Paul Boersma 2023