Search in sources :

Example 11 with InterfaceDecl

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;
}
Also used : FieldDecl(abs.frontend.ast.FieldDecl) ClassDecl(abs.frontend.ast.ClassDecl) VarDecl(abs.frontend.ast.VarDecl) InterfaceTypeUse(abs.frontend.ast.InterfaceTypeUse) InterfaceDecl(abs.frontend.ast.InterfaceDecl) ClassDecl(abs.frontend.ast.ClassDecl) FieldDecl(abs.frontend.ast.FieldDecl) VarDecl(abs.frontend.ast.VarDecl) Decl(abs.frontend.ast.Decl) InterfaceDecl(abs.frontend.ast.InterfaceDecl)

Example 12 with InterfaceDecl

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;
            }
        }
    }
}
Also used : EqExp(abs.frontend.ast.EqExp) DataTypeUse(abs.frontend.ast.DataTypeUse) ABSRef(apet.testCases.ABSRef) DeclNamePredicate(abs.backend.tests.AbsASTBuilderUtil.DeclNamePredicate) NullExp(abs.frontend.ast.NullExp) InterfaceDecl(abs.frontend.ast.InterfaceDecl) PureExp(abs.frontend.ast.PureExp) VarUse(abs.frontend.ast.VarUse)

Example 13 with InterfaceDecl

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);
    }
}
Also used : InterfaceDecl(abs.frontend.ast.InterfaceDecl)

Example 14 with InterfaceDecl

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;
}
Also used : DataConstructorExp(abs.frontend.ast.DataConstructorExp) TypeUse(abs.frontend.ast.TypeUse) ParametricDataTypeUse(abs.frontend.ast.ParametricDataTypeUse) DataTypeUse(abs.frontend.ast.DataTypeUse) ClassDecl(abs.frontend.ast.ClassDecl) VarDeclStmt(abs.frontend.ast.VarDeclStmt) InterfaceDecl(abs.frontend.ast.InterfaceDecl) MainBlock(abs.frontend.ast.MainBlock) HashSet(java.util.HashSet)

Example 15 with InterfaceDecl

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;
}
Also used : NamedImport(abs.frontend.ast.NamedImport) StarImport(abs.frontend.ast.StarImport) FromImport(abs.frontend.ast.FromImport) Import(abs.frontend.ast.Import) ClassDecl(abs.frontend.ast.ClassDecl) StarImport(abs.frontend.ast.StarImport) List(abs.frontend.ast.List) InterfaceDecl(abs.frontend.ast.InterfaceDecl) HashSet(java.util.HashSet) Name(abs.frontend.ast.Name) NamedImport(abs.frontend.ast.NamedImport)

Aggregations

InterfaceDecl (abs.frontend.ast.InterfaceDecl)15 ClassDecl (abs.frontend.ast.ClassDecl)7 Decl (abs.frontend.ast.Decl)3 HashSet (java.util.HashSet)3 Test (org.junit.Test)3 FrontendTest (abs.frontend.FrontendTest)2 DataTypeUse (abs.frontend.ast.DataTypeUse)2 DeltaAccess (abs.frontend.ast.DeltaAccess)2 FieldDecl (abs.frontend.ast.FieldDecl)2 InterfaceTypeUse (abs.frontend.ast.InterfaceTypeUse)2 List (abs.frontend.ast.List)2 MethodImpl (abs.frontend.ast.MethodImpl)2 Model (abs.frontend.ast.Model)2 ModuleDecl (abs.frontend.ast.ModuleDecl)2 DeclNamePredicate (abs.backend.tests.AbsASTBuilderUtil.DeclNamePredicate)1 MethodNamePredicate (abs.backend.tests.AbsASTBuilderUtil.MethodNamePredicate)1 AbsASTBuilderUtil.findMethodImpl (abs.backend.tests.AbsASTBuilderUtil.findMethodImpl)1 AbsASTBuilderUtil.findMethodSig (abs.backend.tests.AbsASTBuilderUtil.findMethodSig)1 Access (abs.frontend.ast.Access)1 AddInterfaceModifier (abs.frontend.ast.AddInterfaceModifier)1