Search in sources :

Example 61 with ClassDecl

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

the class TraitTest method addRemoveModifyMethod.

@Test
public void addRemoveModifyMethod() {
    Model model = assertParseOk("module M;" + "trait T = {Unit myMethod(){ println(\"\"); }} " + "trait T3 = T modifies { Unit myMethod(){ skip; }} " + "class C { uses T3;  }");
    ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
    assertNotNull(cls);
    assertTrue(cls.getMethods().getNumChild() == 0);
    model.applyTraits();
    assertTrue(cls.getMethods().getNumChild() == 1);
    assertTrue(cls.getMethod(0).getBlock().getStmt(0) instanceof SkipStmt);
}
Also used : ClassDecl(abs.frontend.ast.ClassDecl) Model(abs.frontend.ast.Model) SkipStmt(abs.frontend.ast.SkipStmt) Test(org.junit.Test)

Example 62 with ClassDecl

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

the class LocationTypeTests method multipleError.

@Test(expected = LocationTypeCheckerException.class)
public void multipleError() {
    Model m = assertParse("interface I { } class C { [Far] [Near] I i; }", WITH_STD_LIB);
    ClassDecl decl = getFirstClassDecl(m);
    LocationTypeExtension.getLocationTypeFromAnnotations(decl.getField(0).getType());
}
Also used : ClassDecl(abs.frontend.ast.ClassDecl) Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 63 with ClassDecl

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

the class LocationTypeTests method fieldDecl.

@Test
public void fieldDecl() {
    Model m = assertParse("interface I { } class C { [Far] I i; }", WITH_STD_LIB);
    ClassDecl decl = getFirstClassDecl(m);
    LocationType ft = LocationTypeExtension.getLocationTypeFromAnnotations(decl.getField(0).getType());
    assertEquals(LocationType.FAR, ft);
}
Also used : ClassDecl(abs.frontend.ast.ClassDecl) Model(abs.frontend.ast.Model) LocationType(abs.frontend.typechecker.locationtypes.LocationType) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 64 with ClassDecl

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

the class TypingTest method testFieldUse.

@Test
public void testFieldUse() {
    Model m = assertParseOkStdLib(" class C { Bool f; Bool m() { return this.f; } }");
    ClassDecl d = (ClassDecl) m.lookup(new KindedName(Kind.CLASS, "UnitTest.C"));
    FieldDecl f = d.getField(0);
    ReturnStmt s = (ReturnStmt) d.getMethod(0).getBlock().getStmt(0);
    assertEquals(f.getType(), s.getRetExp().getType());
}
Also used : FieldDecl(abs.frontend.ast.FieldDecl) ClassDecl(abs.frontend.ast.ClassDecl) Model(abs.frontend.ast.Model) KindedName(abs.frontend.typechecker.KindedName) ReturnStmt(abs.frontend.ast.ReturnStmt) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Example 65 with ClassDecl

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

the class AnnotationTests method testFieldDecl.

@Test
public void testFieldDecl() {
    Model m = assertParseOkAnn("class C { [Far] I i; }");
    ClassDecl decl = getFirstClassDecl(m);
    assertHasLocAnnotation(decl.getField(0).getType(), "Far");
}
Also used : ClassDecl(abs.frontend.ast.ClassDecl) Model(abs.frontend.ast.Model) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Aggregations

ClassDecl (abs.frontend.ast.ClassDecl)75 Test (org.junit.Test)59 Model (abs.frontend.ast.Model)57 DeltaDecl (abs.frontend.ast.DeltaDecl)22 FrontendTest (abs.frontend.FrontendTest)12 ModifyClassModifier (abs.frontend.ast.ModifyClassModifier)12 SkipStmt (abs.frontend.ast.SkipStmt)11 DeltaTraitModifier (abs.frontend.ast.DeltaTraitModifier)7 InterfaceDecl (abs.frontend.ast.InterfaceDecl)7 MethodImpl (abs.frontend.ast.MethodImpl)7 ModifyMethodModifier (abs.frontend.ast.ModifyMethodModifier)7 TraitExpr (abs.frontend.ast.TraitExpr)7 MethodSig (abs.frontend.ast.MethodSig)6 ReturnStmt (abs.frontend.ast.ReturnStmt)6 AddMethodModifier (abs.frontend.ast.AddMethodModifier)5 Decl (abs.frontend.ast.Decl)5 DeltaAccess (abs.frontend.ast.DeltaAccess)5 List (abs.frontend.ast.List)5 TraitSetExpr (abs.frontend.ast.TraitSetExpr)5 CompilationUnit (abs.frontend.ast.CompilationUnit)4