Search in sources :

Example 26 with ClassDecl

use of org.abs_models.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(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 27 with ClassDecl

use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.

the class AnnotationTests method testMethodParam.

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

Example 28 with ClassDecl

use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.

the class AnnotationTests method testClassParam.

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

Example 29 with ClassDecl

use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.

the class TypingTest method testFieldUse.

@Test
public void testFieldUse() {
    Model m = assertParse(" class C { Bool f; Bool m() { return this.f; } }");
    ClassDecl d = (ClassDecl) m.lookup(new KindedName(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(org.abs_models.frontend.ast.FieldDecl) ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) KindedName(org.abs_models.frontend.typechecker.KindedName) ReturnStmt(org.abs_models.frontend.ast.ReturnStmt) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 30 with ClassDecl

use of org.abs_models.frontend.ast.ClassDecl in project abstools by abstools.

the class TypingTest method testContextDecl.

@Test
public void testContextDecl() {
    Model m = assertParse("class C implements I { I m() { return this; } } interface I { }");
    ClassDecl d = (ClassDecl) m.lookup(new KindedName(KindedName.Kind.CLASS, "C"));
    ReturnStmt s = (ReturnStmt) d.getMethod(0).getBlock().getStmt(0);
    assertEquals(d, s.getRetExp().getContextDecl());
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) KindedName(org.abs_models.frontend.typechecker.KindedName) ReturnStmt(org.abs_models.frontend.ast.ReturnStmt) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Aggregations

ClassDecl (org.abs_models.frontend.ast.ClassDecl)79 Model (org.abs_models.frontend.ast.Model)72 Test (org.junit.Test)72 DeltaDecl (org.abs_models.frontend.ast.DeltaDecl)24 FrontendTest (org.abs_models.frontend.FrontendTest)15 ModifyClassModifier (org.abs_models.frontend.ast.ModifyClassModifier)12 SkipStmt (org.abs_models.frontend.ast.SkipStmt)11 ReturnStmt (org.abs_models.frontend.ast.ReturnStmt)10 KindedName (org.abs_models.frontend.typechecker.KindedName)10 DeltaTraitModifier (org.abs_models.frontend.ast.DeltaTraitModifier)7 ModifyMethodModifier (org.abs_models.frontend.ast.ModifyMethodModifier)7 TraitExpr (org.abs_models.frontend.ast.TraitExpr)7 MethodImpl (org.abs_models.frontend.ast.MethodImpl)6 AddMethodModifier (org.abs_models.frontend.ast.AddMethodModifier)5 MethodSig (org.abs_models.frontend.ast.MethodSig)5 ModuleDecl (org.abs_models.frontend.ast.ModuleDecl)5 TraitSetExpr (org.abs_models.frontend.ast.TraitSetExpr)5 HashSet (java.util.HashSet)4 List (org.abs_models.frontend.ast.List)4 ABSTest (org.abs_models.ABSTest)3