Query the current state.
>
|
kernelopts(assertlevel);
|
Turn assertions on (kernelopts returns its previous value).
>
|
kernelopts(assertlevel=1);
|
The following results in assertion failures.
>
|
ASSERT(type(x,integer),"x must be an integer");
|
Error, assertion failed, x must be an integer
| |
>
|
a:=1: ASSERT(a>5,cat("a is too small: ",a));
|
Error, assertion failed, a is too small: 1
| |
This assertion check will succeed.
>
|
ASSERT(true,"This is ok");
|
Assertion failures are not trappable.
>
|
try ASSERT(false) catch: end try;
|
Turn assertions off (the previous value is returned again).
>
|
kernelopts(assertlevel=0);
|
Now assertion failures are ignored.
>
|
ASSERT(type(x,integer),"x must be an integer");
|