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);
}
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());
}
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);
}
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());
}
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");
}
Aggregations