./
assert.pro
top assert
assert, condition [, msg] [, arg1] [, arg2] [, arg3] [, /skip]
Raises an error if the given condition is not met. Uses logical_predicate
to determine truth of condition: so zero or null values are false, anything
else is true. Be careful of conditions like the following:
assert, not file_test(filename)
not
operator and therefore this assertation is
always false.
ASSERT
clears math errors to eliminate messages about math errors in
MGUNIT
output.
Parameters
- condition in required type=boolean
condition to assert
- msg in optional type=string default='Assertion failed'
message to throw if condition is not met
- arg1 in optional type=string
first argument for any C format codes in msg
- arg2 in optional type=string
second argument for any C format codes in msg
- arg3 in optional type=string
third argument for any C format codes in msg
Keywords
- skip in optional type=boolean
set to skip the current test instead of passing or failing
Examples
It is typical to check the error in a calculation like the following:
assert, error gt tolerance, 'incorrect result, error = %f', error
assert, long((strsplit(!version.release, ',', /extract))[0]) ge 8, $
'IDL version too old: %s', !version.release, $
/skip
File attributes
Modification date: | Tue Feb 21 13:10:09 2012 |
Lines: | 61 |
Docformat: | rst rst |