expression evaluating to true or false
ASSERT is used to guarantee pre- and post-conditions while a Maple procedure is executing.
If the first argument evaluates to false, an error is generated and the second argument is printed in order to identify the nature of the failure. Such an error cannot be trapped via try-catch.
If the first argument evaluates to true, ASSERT returns NULL.
The ASSERT mechanism can be turned on and off with kernelopts. If turned off, the overhead of processing an ASSERT is negligible.
The ASSERT command is thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
Query the current state.
Turn assertions on (kernelopts returns its previous value).
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⁡5<a,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;
Error, assertion failed
Turn assertions off (the previous value is returned again).
Now assertion failures are ignored.
ASSERT(type(x,integer),"x must be an integer");
Download Help Document
What kind of issue would you like to report? (Optional)