public final class CheckRepContract extends ObjectContract
@CheckRep annotation, and have return type boolean or void. In the first
case, a return value true means the check passed, and false, or an exception,
means it failed. In the second case, normal return means the check passed, and an exception means
it failed.| Modifier and Type | Field and Description |
|---|---|
java.lang.reflect.Method |
checkRepMethod |
java.lang.Class<?> |
declaringClass |
private TypedClassOperation |
operation |
(package private) boolean |
returnsBoolean |
| Constructor and Description |
|---|
CheckRepContract(java.lang.reflect.Method checkRepMethod) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(@Nullable java.lang.Object o) |
boolean |
evaluate(java.lang.Object... objects)
Evaluates the contract on the given values.
|
java.lang.String |
get_observer_str()
Returns a string describing the observer.
|
int |
getArity()
The number of values that this contract is over.
|
TypeTuple |
getInputTypes()
Returns the input types for this contract.
|
int |
hashCode() |
java.lang.String |
toCodeString()
A string that can be used as Java source code and will result in the expression being
evaluated.
|
java.lang.String |
toCommentString()
A string that will be inserted as a comment in the test before the code corresponding to this
contract.
|
checkContract, failedContract, toStringHandleExceptionspublic final java.lang.reflect.Method checkRepMethod
private final TypedClassOperation operation
boolean returnsBoolean
public final java.lang.Class<?> declaringClass
public CheckRepContract(java.lang.reflect.Method checkRepMethod)
public boolean equals(@Nullable java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean evaluate(java.lang.Object... objects)
throws java.lang.Throwable
ObjectContractfalse if the contract was violated.
Returns true if the contract was satisfied or was not applicable.
When calling this method during execution of a test, Randoop guarantees that objects
does not contain any null objects, and that objects.length == getArity().
evaluate in class ObjectContractobjects - the actual parameters to this contractjava.lang.Throwable - if an exception is thrown in evaluationpublic int getArity()
ObjectContractgetArity in class ObjectContractpublic TypeTuple getInputTypes()
ObjectContractgetInputTypes in class ObjectContractpublic java.lang.String toCommentString()
ObjectContracttoCommentString in class ObjectContractpublic java.lang.String get_observer_str()
ObjectContractget_observer_str in class ObjectContractpublic java.lang.String toCodeString()
ObjectContractThe N-th object that participates in the contract check should be referred to as "xN" (for N
one of 0, ... , 9). For example, if the expression of arity 2 represents a call of the equals
method between two objects, the code should be something like assert x0.equals(x1);".
The string does not contain a trailing newline. When there is a leading comment, it should start with a newline.
toCodeString in class ObjectContract