Assertion

assert


[%assert: condition; message?]

Verifies that condition is true before continuing program execution.

If condition is false, raises a runtime error; otherwise, does nothing.

The message displayed in the runtime error can be customized by passing a string to message.

Parameters

conditionbool
The condition to check.

messagestring (optional)
The error message to display if the condition is not satisfied.

Examples

# does absolutely nothing
[assert: @true]

# [assertion error] assertion failed: condition was false
[assert: @false]

# [assertion error] ooooops!
[assert: @false; "ooooops!"] 

assert-eq


[%assert-eq: actual; expected; message?]

Verifies that expected and actual are equal before continuing program execution.

Like [assert], a custom error message can be provided.

Parameters

actualany
The actual value to test.

expectedany
The expected value to test against.

messagestring
The error message to display if the condition is not satisfied.

assert-neq


[%assert-neq: actual; unexpected; message?]

Verifies that unexpected and actual are not equal before continuing program execution.

Like [assert], a custom error message can be provided.

Parameters

actualany
The actual value to test.

unexpectedany
The unexpected value to test against.

messagestring
The error message to display if the condition is not satisfied.