use of abs.frontend.ast.NullExp in project abstools by abstools.
the class PureExpressionBuilder method createPureExpression.
/**
* @param currentHeapReference
* @param initialisationsOrders
* @param heapNames
* @param dataValue
* @return
*/
PureExp createPureExpression(String currentHeapReference, List<String> initialisationsOrders, String testName, Set<String> heapNames, ABSData dataValue) {
String type = getABSDataType(dataValue);
String value = getABSDataValue(dataValue);
if (type.contains("(") && dataValue instanceof ABSTerm) {
ABSTerm term = (ABSTerm) dataValue;
type = getABSTermTypeName(term);
}
// import type
Decl decl = getDecl(model, Decl.class, namePred(type));
importType(decl);
if (dataValue instanceof ABSTerm) {
ABSTerm term = (ABSTerm) dataValue;
return makeDataTermValue(currentHeapReference, initialisationsOrders, testName, heapNames, term, decl);
} else if (dataValue instanceof ABSRef) {
if (heapNames.contains(value)) {
String ref = heapRefBuilder.heapReferenceForTest(testName, value);
if (currentHeapReference != null) {
// we need to consider initialisation order!
updateInitialisationOrder(initialisationsOrders, currentHeapReference, ref);
}
return new VarUse(ref);
} else {
return new NullExp();
}
} else {
throw new IllegalStateException("Cannot handle ABSData that is not " + "either a ABSRef or a ABSTerm");
}
}
use of abs.frontend.ast.NullExp in project abstools by abstools.
the class ABSUnitTestCaseBuilder method makeOracle.
void makeOracle(String testName, Set<String> heapNames, Map<ABSRef, ABSObject> finalHeap, String actual, Access access, ABSData data, Set<String> visited, Block block) {
InterfaceDecl inf = null;
if (access instanceof DataTypeUse) {
inf = getDecl(model, InterfaceDecl.class, new DeclNamePredicate<InterfaceDecl>(((DataTypeUse) access).getName()));
}
PureExp exp = pureExpBuilder.createPureExpression(testName, heapNames, data);
block.addStmtNoTransform(getExpStmt(getCall(new VarUse(ASSERT_HELPER), "assertTrue", true, new EqExp(new VarUse(actual), exp))));
if (inf != null && !(exp instanceof NullExp)) {
String ref = getABSDataValue(data);
for (ABSRef r : finalHeap.keySet()) {
if (getABSDataValue(r).equals(ref)) {
makeGetAndAssertStatementsForHeapRef(testName, heapNames, finalHeap, r, finalHeap.get(r), visited, block);
break;
}
}
}
}
Aggregations