public final class PrimValue extends ObjectContract
var3 == 1
where var3
is an integer-valued variable in a Randoop test).Modifier and Type | Class and Description |
---|---|
static class |
PrimValue.EqualityMode
Specifies what type of equality the contract uses.
|
Modifier and Type | Field and Description |
---|---|
private PrimValue.EqualityMode |
equalityMode
Whether to use
== or .equals() to test for equality. |
(package private) static TypeTuple |
inputTypes
The arguments to which this contract can be applied.
|
java.lang.Object |
value
The expected run-time value.
|
Constructor and Description |
---|
PrimValue(java.lang.Object value,
PrimValue.EqualityMode equalityMode) |
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.
|
java.lang.String |
toString() |
checkContract, failedContract, toStringHandleExceptions
public final java.lang.Object value
private final PrimValue.EqualityMode equalityMode
==
or .equals()
to test for equality.static TypeTuple inputTypes
public PrimValue(java.lang.Object value, PrimValue.EqualityMode equalityMode)
value
- the value for the expression: a primitive value or stringequalityMode
- what equality test the assertion usespublic boolean equals(@Nullable java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean evaluate(java.lang.Object... objects) throws java.lang.Throwable
ObjectContract
false
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 ObjectContract
objects
- the actual parameters to this contractjava.lang.Throwable
- if an exception is thrown in evaluationpublic int getArity()
ObjectContract
getArity
in class ObjectContract
public TypeTuple getInputTypes()
ObjectContract
getInputTypes
in class ObjectContract
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String get_observer_str()
ObjectContract
get_observer_str
in class ObjectContract
public java.lang.String toCodeString()
ObjectContract
The 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
public java.lang.String toCommentString()
ObjectContract
toCommentString
in class ObjectContract