assert

Assert

In Cyan, we have a simple method to check the validity of an evaluated expression. Macro assert generates code that checks at runtime whether its argument is true. It issues a warning if it is not.

assert 1 – 1 == 0; // ok
assert 0 == 1; // runtime error

In resume, assert is a macro for testing an expression and can be used along with any type or literal

assert Person getName == “Marcia”;
assert Int*Int + Int == 0;

Even with Java types

var java.lang.Integer integer = Integer(5);
assert 5 == integer;