Maple Professional
Maple Academic
Maple Student Edition
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professional
MapleSim Academic
Maple T.A. - Testing & Assessment
Maple T.A. MAA Placement Test Suite
Möbius - Online Courseware
Machine Design / Industrial Automation
Aerospace
Vehicle Engineering
Robotics
Power Industries
System Simulation and Analysis
Model development for HIL
Plant Modeling for Control Design
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematics Education
Engineering Education
High Schools & Two-Year Colleges
Testing & Assessment
Students
Financial Modeling
Operations Research
High Performance Computing
Physics
Live Webinars
Recorded Webinars
Upcoming Events
MaplePrimes
Maplesoft Blog
Maplesoft Membership
Maple Ambassador Program
MapleCloud
Technical Whitepapers
E-Mail Newsletters
Maple Books
Math Matters
Application Center
MapleSim Model Gallery
User Case Studies
Exploring Engineering Fundamentals
Teaching Concepts with Maple
Maplesoft Welcome Center
Teacher Resource Center
Student Help Center
ASSERT - check assertions
Calling Sequence
ASSERT(cond, string)
ASSERT(cond)
Parameters
cond
-
expression evaluating to true or false
string
Description
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.
Thread Safety
The ASSERT command is thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
Examples
Query the current state.
Turn assertions on (kernelopts returns its previous value).
The following results in assertion failures.
Error, assertion failed, x must be an integer
Error, assertion failed, a is too small: 1
This assertion check will succeed.
Assertion failures are not trappable.
Turn assertions off (the previous value is returned again).
Now assertion failures are ignored.
See Also
kernelopts, try
Download Help Document