assert(prog_tools) Prog_Tools assert(prog_tools)
NAME
assert - checks a condition and prints an error message if
the condition fails
DESCRIPTION
The assert object is similar to the assert macro in the C
programming language. Instances of the assert class can
be used throughout scripts to document various assumptions
and print error messages when the assumptions are violated. By default, a failed assertion will cause the
parser to exit, but this can be changed by sending a continue_on_failure_on! message to the instance (or the
assert class to affect the behaviour of all subsequently
created assertions). The assert class is a subclass of
logic. Therefore, all messages valid with a logic object
are also valid with assert objects.
SUPERCLASS
logic
INSTANCE VARIABLES
continue_on_failure
a boolean value that indicates what should happen
on a failed assertion. If this variable is set to
true, the normal error message will be printed out
but the parser will continue. If the variable is
set to false (the default), then the parser will
exit once the error message is printed out.
checking_for
a string value that is printed out if the assertion
fails.
MESSAGES
continue_on_failure_off!
causes execution to stop after a failed assertion.
An error message is printed out indicating the
failed assertion.
continue_on_failure_on!
causes execution to continue after a failed assertion. The error message is still printed out however.
check! checks the value of the assertion. If it is
nonzero, an error message is printed out. Execution is suspended if the continue_on_failure
instance variable is set to false.
checking_for[=?]
set/get the value of the checking_for instance
variable.
EXAMPLE
SEE ALSO
logic
Please send comments and suggestions toconsult@rpi.edu