|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectExecutableSequence
public class ExecutableSequence extends Object implements Serializable
An ExecutableSequence wraps a Sequence with functionality for
executing the sequence. It also lets the client add Checks to
that check expected behaviors of the execution.
An ExecutableSequence augments a sequence with three additional pieces of data:
NotNull check to the ith index
of a sequence to signify that the value returned by the statement at index i
should not be null.
Of the three pieces of data above, an ExecutableSequence only directly manages
the first one, i.e. the execution results. Other pieces of data, including
checks and check evaluation results, are added or removed by the
client of the ExecutableSequence. One way of doing this is by implementing an
ExecutionVisitor and passing it as an argument to the execute
method.
The ethod execute(ExecutionVisitor v) executes the code that the
sequence represents. This method uses reflection to execute each element in the
sequence (method call, constructor call, primitive or array declaration, etc).
Before executing each statement (e.g. the i-th statement), execute(v)
calls v.visitBefore(this, i), and after executing each statement, it calls
v.visitAfter(this, i). The purpose of the visitor is to examine the unfolding
execution, and take some action depending on its intended purpose. For example,
it may decorate the sequence with Checks about the
execution.
NOTES.
| Modifier and Type | Field and Description |
|---|---|
protected List<List<Check>> |
checks
|
protected List<List<Boolean>> |
checksResults
|
long |
exectime
|
protected Execution |
executionResults
|
long |
gentime
|
Sequence |
sequence
|
| Constructor and Description |
|---|
ExecutableSequence(Sequence sequence)
Create an executable sequence that executes the given sequence. |
ExecutableSequence(Sequence sequence,
Execution exec,
List<List<Check>> checks)
Create an executable sequence directly using the given arguments. |
| Modifier and Type | Method and Description | |
|---|---|---|
void |
addCheck(int i,
Check check,
boolean passed)
Adds the given check to the i-th element of the sequence. |
|
static int |
checks_count(List<ExecutableSequence> seqs)
Return the total number of checks in a list of sequences |
|
int |
compare_checks(ExecutableSequence es,
boolean remove_diffs,
boolean print_diffs)
Compares the results of the checks of two sequences (the code in each sequence should be the same). |
|
ExecutableSequence |
duplicate()
|
|
boolean |
equals(Object obj)
|
|
int |
exceptionIndex()
Returns the index i for which this.isExceptionalExecution(i), or -1 if there is no such index. |
|
void |
execute(ExecutionVisitor visitor)
Executes sequence, stopping on exceptions |
|
void |
execute(ExecutionVisitor visitor,
boolean stop_on_exception)
Execute this sequence, invoking the given visitor as the execution unfolds. |
|
int |
executedSize()
|
|
static void |
executeStatement(Sequence s,
List<ExecutionOutcome> outcome,
int index,
Object[] inputVariables)
|
|
ExecutionOutcome[] |
getAllResults()
|
|
List<Check> |
getChecks(int i)
Get the checks for the i-th element of the sequence. |
|
List<Check> |
getChecks(int i,
Class<? extends Check> clazz)
|
|
List<List<Boolean>> |
getChecksResults()
|
|
int |
getContractCheckIndex(Class<? extends Check> clazz)
|
|
int |
getExceptionIndex(Class<?> exceptionClass)
|
|
int |
getFailureIndex()
|
|
List<Check> |
getFailures(int idx)
|
|
ExecutionOutcome |
getResult(int index)
This method is typically used by ExecutionVisitors. |
|
static boolean |
getRuntimeInputs(Sequence s,
List<ExecutionOutcome> outcome,
int i,
List<Variable> inputs,
Object[] runtimeObjects)
|
|
protected static Object[] |
getRuntimeValuesForVars(List<Variable> vars,
List<ExecutionOutcome> execution)
|
|
static
|
getSequences(List<ExecutableSequence> exec)
|
|
boolean |
hasCheck(Class<? extends Check> clazz)
|
|
boolean |
hasCheck(int i,
Class<? extends Check> clazz)
True iff this sequences has at least one check of the given type at index i. |
|
boolean |
hasChecks(int i)
|
|
boolean |
hasFailure()
|
|
boolean |
hasFailure(int i)
|
|
int |
hashCode()
|
|
boolean |
hasNonExecutedStatements()
|
|
boolean |
isNormalExecution()
|
|
boolean |
isNormalExecution(int i)
This method is typically used by ExecutionVisitors. |
|
void |
removeChecks()
|
|
int |
seq_id()
Returns an id based on the contents of the sequence alone. |
|
boolean |
throwsException()
|
|
boolean |
throwsException(Class<?> exceptionClass)
|
|
String |
toCodeString()
Output this sequence as code. |
|
String |
toString()
|
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public Sequence sequence
protected List<List<Check>> checks
protected List<List<Boolean>> checksResults
protected transient Execution executionResults
public long gentime
public long exectime
| Constructor Detail |
|---|
public ExecutableSequence(Sequence sequence)
public ExecutableSequence(Sequence sequence,
Execution exec,
List<List<Check>> checks)
| Method Detail |
|---|
public List<Check> getChecks(int i)
public void addCheck(int i,
Check check,
boolean passed)
IllegalArgumentException - If the given check's class is StatementThrowsException and
there is already an check of this class at the give index.public String toString()
toString in class Objectpublic int seq_id()
public String toCodeString()
public void execute(ExecutionVisitor visitor)
public void execute(ExecutionVisitor visitor,
boolean stop_on_exception)
getResult(i).
visitor.initialize(this).
visitBefore method. After executing
each statement, calls the visitor's visitAfter method.
stop_on_exception==true.
visitAfter method, a ContractViolation
check is present at index i.
visitor - can be null, in which case no visitor will be invoked
during execution.
public static boolean getRuntimeInputs(Sequence s,
List<ExecutionOutcome> outcome,
int i,
List<Variable> inputs,
Object[] runtimeObjects)
protected static Object[] getRuntimeValuesForVars(List<Variable> vars,
List<ExecutionOutcome> execution)
public static void executeStatement(Sequence s,
List<ExecutionOutcome> outcome,
int index,
Object[] inputVariables)
public ExecutionOutcome getResult(int index)
public List<List<Boolean>> getChecksResults()
public ExecutionOutcome[] getAllResults()
public int executedSize()
public boolean isNormalExecution(int i)
public boolean isNormalExecution()
public List<Check> getChecks(int i,
Class<? extends Check> clazz)
public void removeChecks()
public boolean hasCheck(Class<? extends Check> clazz)
public int getContractCheckIndex(Class<? extends Check> clazz)
public boolean hasCheck(int i,
Class<? extends Check> clazz)
public boolean hasChecks(int i)
public boolean hasFailure(int i)
public boolean hasFailure()
public List<Check> getFailures(int idx)
public int getFailureIndex()
public int getExceptionIndex(Class<?> exceptionClass)
public boolean throwsException(Class<?> exceptionClass)
public boolean throwsException()
public boolean hasNonExecutedStatements()
public ExecutableSequence duplicate()
public int exceptionIndex()
public static <D extends Check> List<Sequence> getSequences(List<ExecutableSequence> exec)
public int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Object
public int compare_checks(ExecutableSequence es,
boolean remove_diffs,
boolean print_diffs)
public static int checks_count(List<ExecutableSequence> seqs)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||