The assert()
statement is a convenient mechanism for incorporating diagnostic tests in code. Expressions used with the standard assert
statement should not have side effects. Typically, the behavior of the assert
statement depends on the status of a runtime property. If definedenabled, the assert
statement is defined designed to evaluate its expression argument and throw an AssertionError
if the result of the expression is convertible to false
. If undefineddisabled, assert
is defined to be a no-opoperation. Consequently, any side effects resulting from evaluation of the expression in the assertion are lost in non-debugging versions of the production quality code.
Noncompliant Code Example
...