public final class ObserverEqArray extends ObjectContract
ObserverEqArray checks are not checks that must hold of all objects of a given class (unlike a
check like EqualsReflexive, which must hold for any objects, no matter its execution
context).
| Modifier and Type | Field and Description |
|---|---|
private static double |
DOUBLE_DELTA
The maximum difference for which doubles are considered equal.
|
private static float |
FLOAT_DELTA
The maximum difference for which floats are considered equal.
|
(package private) static TypeTuple |
inputTypes
The arguments to which this contract can be applied.
|
private java.lang.Object |
value
The run-time result of calling the observer: an array of literals.
|
| Constructor and Description |
|---|
ObserverEqArray(java.lang.Object value,
AccessibilityPredicate isAccessible)
Creates a new ObserverEqArray.
|
| Modifier and Type | Method and Description |
|---|---|
private java.lang.String |
arrayComponentsToString()
Returns a string representation of the components of the array, enclosed in curly braces, as it
would appear in Java source code.
|
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() |
static boolean |
isLiteralType(java.lang.Object value,
AccessibilityPredicate isAccessible)
Returns true if the value can be represented as a literal in Java source code.
|
private java.lang.String |
newArrayExpression()
Returns a Java array constructor expression for this, e.g., "new int[] {1,2,3}".
|
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.
|
java.lang.String |
toString() |
checkContract, failedContract, toStringHandleExceptionsprivate java.lang.Object value
private static final double DOUBLE_DELTA
private static final float FLOAT_DELTA
static TypeTuple inputTypes
public ObserverEqArray(java.lang.Object value,
AccessibilityPredicate isAccessible)
value - the run-time result of calling the observer: an array of literalsisAccessible - the accessibility predicatepublic static boolean isLiteralType(java.lang.Object value,
AccessibilityPredicate isAccessible)
value - an objectisAccessible - the accessibility predicatepublic boolean equals(@Nullable java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic 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 ObjectContractprivate java.lang.String newArrayExpression()
private java.lang.String arrayComponentsToString()
public 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 toString()
toString in class java.lang.Object