Package randoop.condition
Class ExecutableSpecification
java.lang.Object
randoop.condition.ExecutableSpecification
The executable version of an
OperationSpecification
. It
allows the underlying Boolean expressions to be evaluated.
It is represented as three collections: a collection of ExecutableBooleanExpression
for the Precondition
, a collection of GuardPropertyPair
for the Postcondition
, and a
collection of GuardThrowsPair
for the ThrowsCondition
in a specification.
It includes specifications inherited from supertypes.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final List<GuardPropertyPair>
TheGuardThrowsPair
objects for thePostcondition
s of the operation.private final List<GuardThrowsPair>
TheGuardThrowsPair
objects for theThrowsCondition
s of the operation.private List<ExecutableSpecification>
Mirrors the overrides/implements relation among methods.private final List<ExecutableBooleanExpression>
TheExecutableBooleanExpression
objects for thePrecondition
s of the operation. -
Constructor Summary
ConstructorDescriptionCreates an emptyExecutableSpecification
object.ExecutableSpecification
(List<ExecutableBooleanExpression> preExpressions, List<GuardPropertyPair> guardPropertyPairs, List<GuardThrowsPair> guardThrowsPairs) Creates anExecutableSpecification
object for the lists of guard expressions for pre-specifications,GuardPropertyPair
objects for post-specifications, andGuardThrowsPair
objects for throws-specifications. -
Method Summary
Modifier and TypeMethodDescription(package private) void
addParent
(ExecutableSpecification parentExecSpec) Add the parentExecutableSpecification
for this collection.private ExecutableBooleanExpression
checkGuardPropertyPairs
(Object[] args) Tests the given argument values against the guards of local postconditions, which are theGuardPropertyPair
objects in thisExecutableSpecification
.private List<ThrowsClause>
checkGuardThrowsPairs
(Object[] args) Evaluate the guard of each localGuardThrowsPair
, and for each one satisfied, add theThrowsClause
to the set of expected exceptions.private boolean
checkPreExpressions
(Object[] args) Tests the given argument values against the local preconditions, which are theExecutableBooleanExpression
objects inpreExpressions
in thisExecutableSpecification
.checkPrestate
(Object[] args) Check all guard expressions of the method's full specification, which includes thisExecutableSpecification
and those of any overridden/implemented method.private void
checkPrestate
(Object[] args, ExpectedOutcomeTable table) Modifies the given table, adding anExpectedOutcomeTable
entry for the guard expressions of this method's local specification recording the following: Whether thepreExpressions
fail or are satisfied.boolean
isEmpty()
Indicates whether the full specification is empty: thisExecutableSpecification
, and any member of the parent list, has no guard expresions, no property pairs, and no throws pairs.toString()
-
Field Details
-
preExpressions
TheExecutableBooleanExpression
objects for thePrecondition
s of the operation. -
guardPropertyPairs
TheGuardThrowsPair
objects for thePostcondition
s of the operation. -
guardThrowsPairs
TheGuardThrowsPair
objects for theThrowsCondition
s of the operation. -
parentList
Mirrors the overrides/implements relation among methods. If this ExecutableSpecification is the local specification for method declaration m, theparentList
contains one element for each method that m overrides or implements (and has specifications).
-
-
Constructor Details
-
ExecutableSpecification
public ExecutableSpecification()Creates an emptyExecutableSpecification
object. -
ExecutableSpecification
public ExecutableSpecification(List<ExecutableBooleanExpression> preExpressions, List<GuardPropertyPair> guardPropertyPairs, List<GuardThrowsPair> guardThrowsPairs) Creates anExecutableSpecification
object for the lists of guard expressions for pre-specifications,GuardPropertyPair
objects for post-specifications, andGuardThrowsPair
objects for throws-specifications.- Parameters:
preExpressions
- the operation pre-specificationsguardPropertyPairs
- the operation post-specificationsguardThrowsPairs
- the operation throws-specifications
-
-
Method Details
-
checkPrestate
Check all guard expressions of the method's full specification, which includes thisExecutableSpecification
and those of any overridden/implemented method.- Parameters:
args
- the argument values to test the guard expressions; always includes a receiver (null for static methods)- Returns:
- the table with entries for this operation
- See Also:
-
checkPrestate
Modifies the given table, adding anExpectedOutcomeTable
entry for the guard expressions of this method's local specification recording the following:- Whether the
preExpressions
fail or are satisfied. SeecheckPreExpressions(java.lang.Object[])
. - A set of
ThrowsClause
objects for expected exceptions. SeecheckGuardThrowsPairs(java.lang.Object[])
. - The expected
ExecutableBooleanExpression
, if any. SeecheckGuardPropertyPairs(java.lang.Object[])
.
- Parameters:
args
- the argument values; always includes a receiver (null for static methods)table
- the table to which the created entry is to be added
- Whether the
-
checkPreExpressions
Tests the given argument values against the local preconditions, which are theExecutableBooleanExpression
objects inpreExpressions
in thisExecutableSpecification
.- Parameters:
args
- the argument values- Returns:
- false if any local precondition fails on the argument values, true if all succeed
-
checkGuardThrowsPairs
Evaluate the guard of each localGuardThrowsPair
, and for each one satisfied, add theThrowsClause
to the set of expected exceptions.- Parameters:
args
- the argument values- Returns:
- the set of exceptions for which the guard expression evaluated to true
-
checkGuardPropertyPairs
Tests the given argument values against the guards of local postconditions, which are theGuardPropertyPair
objects in thisExecutableSpecification
. Returns theExecutableBooleanExpression
from the first pair whose guard expression evaluated to true.- Parameters:
args
- the argument values- Returns:
- the property for the first
GuardPropertyPair
for which the guard expression evaluates to true; null if there is none
-
addParent
Add the parentExecutableSpecification
for this collection.- Parameters:
parentExecSpec
- theExecutableSpecification
to which to link
-
isEmpty
public boolean isEmpty()Indicates whether the full specification is empty: thisExecutableSpecification
, and any member of the parent list, has no guard expresions, no property pairs, and no throws pairs.- Returns:
- true if there are no guard expressions, or property or throws pairs in this or the parent list, false otherwise
-
toString
-