|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object structure.Assert
public class Assert
A library of assertion testing and debugging procedures.
This class of static methods provides basic assertion testing facilities. An assertion is a condition that is expected to be true at a certain point in the code. Each of the assertion-based routines in this class perform a verification of the condition, and do nothing (aside from testing side-effects) if the condition holds. If the condition fails, however, the assertion throws an exception and prints the associated message, that describes the condition that failed. Basic support is provided for testing general conditions, and pre- and postconditions. There is also a facility for throwing a failed condition for code that should not be executed.
Features similar to assertion testing are expected to be incorporated into the Java 2 language beginning in SDK 1.4.
The debugging facilities provide control that is slightly improved over print statements.
Method Summary | |
---|---|
static void |
condition(boolean test,
java.lang.String message)
Test a general condition. |
static void |
debug(int level,
java.lang.String message)
Set up a debugging message at a specific level. |
static void |
debug(java.lang.String message)
Set up a level 1 debugging message. |
static void |
debugging()
Increase the verbosity of the debugging messages. |
static int |
debugLevel(int level)
Explictly set the debugging level (0 = none) |
static void |
fail(java.lang.String message)
Indicate certain failure. |
static void |
invariant(boolean test,
java.lang.String message)
Test a loop invariant. |
static void |
post(boolean test,
java.lang.String message)
Test a postcondition. |
static void |
pre(boolean test,
java.lang.String message)
Test a precondition. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void debugging()
public static int debugLevel(int level)
level
- the desired level of verosity
level
public static void debug(java.lang.String message)
message
- a string to be printed if debugging level is 1 or morepublic static void debug(int level, java.lang.String message)
level
- the level that triggers the printing of messagemessage
- the message to be printed at the desired levellevel
or morepublic static void pre(boolean test, java.lang.String message)
test
- A boolean expression describing precondition.message
- A string describing precondition.public static void post(boolean test, java.lang.String message)
test
- A boolean expression describing postcondition.message
- A string describing postcondition.public static void condition(boolean test, java.lang.String message)
test
- A boolean expression describing the condition.message
- A string describing the condition.public static void invariant(boolean test, java.lang.String message)
test
- A boolean expression describing the condition.message
- A string describing the condition.public static void fail(java.lang.String message)
message
- A string describing the reason for failure.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |