use of abs.frontend.ast.InterfaceDecl in project abstools by abstools.
the class InferMain method shouldBeConsidered.
private boolean shouldBeConsidered(LocationTypeVariable ltv) {
ASTNode<?> node = ltv.getNode();
Decl contextDecl = node.getContextDecl();
if (contextDecl != null) {
// Don't print interface annotations in "implements/extends" clauses:
if (node instanceof InterfaceTypeUse && (contextDecl instanceof ClassDecl || contextDecl instanceof InterfaceDecl))
return false;
if (contextDecl.isClass() && !config.contains(Config.CLASSES))
return false;
if (contextDecl.isInterface() && !config.contains(Config.INTERFACES))
return false;
if (contextDecl.isFunction() && !config.contains(Config.FUNCTIONS))
return false;
}
if (node instanceof VarDecl && !config.contains(Config.LOCAL_VAR_DECLS))
return false;
if (node instanceof FieldDecl && !config.contains(Config.FIELDS))
return false;
if (ltv.getAnnotatedType() != null) {
return false;
}
return true;
}
use of abs.frontend.ast.InterfaceDecl 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;
}
}
}
}
use of abs.frontend.ast.InterfaceDecl in project abstools by abstools.
the class ABSUnitTestCaseTranslator method generateABSUnitTest.
void generateABSUnitTest(List<TestCase> cs, String mn) {
String[] sp = mn.split("\\.");
final String methodName;
final String className;
if (sp.length == 2) {
className = sp[0];
methodName = sp[1];
} else if (sp.length == 1) {
className = null;
methodName = mn;
} else {
throw new IllegalArgumentException();
}
InterfaceDecl ti = createTestFixture(cs.size(), className, methodName);
if (className == null) {
createTestSuiteForFunction(cs, ti, methodName);
} else {
createTestSuiteForClassMethod(cs, ti, className, methodName);
}
}
use of abs.frontend.ast.InterfaceDecl in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateMainBlockAST.
private MainBlock generateMainBlockAST(List<Import> list) {
final MainBlock block = new MainBlock();
DataConstructorExp empty = new DataConstructorExp("EmptySet", new List<>());
VarDeclStmt futsStatement = getVarDecl(futs, getType("Set", getFutUnitType()), empty);
block.addStmtNoTransform(futsStatement);
VarDeclStmt futStatement = getVarDecl(fut, getFutUnitType(), null);
block.addStmtNoTransform(futStatement);
Set<TypeUse> use = new HashSet<>();
for (InterfaceDecl key : tests.keySet()) {
for (ClassDecl clazz : tests.get(key)) {
use.addAll(generateTestClassImplAST(key, clazz, block));
}
}
block.addStmtNoTransform(generateWaitSyncAST());
return block;
}
use of abs.frontend.ast.InterfaceDecl in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateImportsAST.
private List<Import> generateImportsAST() {
List<Import> imports = new List<>();
Set<String> mn = new HashSet<>();
Set<String> qn = new HashSet<>();
for (InterfaceDecl key : tests.keySet()) {
getImportsFrom(mn, qn, key.getModuleDecl());
for (ClassDecl clazz : tests.get(key)) {
getImportsFrom(mn, qn, clazz.getModuleDecl());
}
}
for (String m : mn) {
imports.add(new StarImport(m));
}
if (!qn.isEmpty()) {
List<Name> names = new List<>();
for (String q : qn) {
names.add(new Name(q));
}
imports.add(new NamedImport(names));
}
return imports;
}
Aggregations