Search in sources :

Example 1 with InitBlock

use of abs.frontend.ast.InitBlock in project abstools by abstools.

the class ABSUnitTestCaseTranslatorHelper method createTestClass.

ClassDecl createTestClass(InterfaceDecl inf) {
    ClassDecl ct = new ClassDecl(testCaseNameBuilder.className(inf.getName()), new abs.frontend.ast.List<Annotation>(), new abs.frontend.ast.List<ParamDecl>(), new abs.frontend.ast.List<InterfaceTypeUse>(), new Opt<InitBlock>(), new abs.frontend.ast.List<CaseBranchStmt>(), new abs.frontend.ast.List<FieldDecl>(), new abs.frontend.ast.List<MethodImpl>());
    ct.addAnnotation(getTestAnnotation(suiteType));
    ct.addImplementedInterfaceUse(new InterfaceTypeUse(inf.getName(), new abs.frontend.ast.List<abs.frontend.ast.Annotation>()));
    for (MethodSig m : inf.getAllMethodSigs()) {
        ct.addMethod(createMethodImpl(m));
    }
    FieldDecl assertImpl = new FieldDecl();
    assertImpl.setName(ASSERT_HELPER);
    assertImpl.setAccess(absAssertImpl.getImplementedInterfaceUse(0).treeCopyNoTransform());
    ct.addField(assertImpl);
    InitBlock block = new InitBlock();
    block.addStmtNoTransform(getVAssign(ASSERT_HELPER, newObj(absAssertImpl, false)));
    ct.setInitBlock(block);
    return ct;
}
Also used : InitBlock(abs.frontend.ast.InitBlock) CaseBranchStmt(abs.frontend.ast.CaseBranchStmt) Annotation(abs.frontend.ast.Annotation) FieldDecl(abs.frontend.ast.FieldDecl) AbsASTBuilderUtil.createMethodSig(abs.backend.tests.AbsASTBuilderUtil.createMethodSig) MethodSig(abs.frontend.ast.MethodSig) ClassDecl(abs.frontend.ast.ClassDecl) AbsASTBuilderUtil.createMethodImpl(abs.backend.tests.AbsASTBuilderUtil.createMethodImpl) MethodImpl(abs.frontend.ast.MethodImpl) ParamDecl(abs.frontend.ast.ParamDecl) InterfaceTypeUse(abs.frontend.ast.InterfaceTypeUse)

Aggregations

AbsASTBuilderUtil.createMethodImpl (abs.backend.tests.AbsASTBuilderUtil.createMethodImpl)1 AbsASTBuilderUtil.createMethodSig (abs.backend.tests.AbsASTBuilderUtil.createMethodSig)1 Annotation (abs.frontend.ast.Annotation)1 CaseBranchStmt (abs.frontend.ast.CaseBranchStmt)1 ClassDecl (abs.frontend.ast.ClassDecl)1 FieldDecl (abs.frontend.ast.FieldDecl)1 InitBlock (abs.frontend.ast.InitBlock)1 InterfaceTypeUse (abs.frontend.ast.InterfaceTypeUse)1 MethodImpl (abs.frontend.ast.MethodImpl)1 MethodSig (abs.frontend.ast.MethodSig)1 ParamDecl (abs.frontend.ast.ParamDecl)1