Search in sources :

Example 11 with KindedName

use of org.abs_models.frontend.typechecker.KindedName in project abstools by abstools.

the class TypingTest method testNew.

@Test
public void testNew() {
    Model m = assertParse("interface I {} class C implements I {} { I i; i = new local C(); }");
    assertEquals(m.lookup(new KindedName(KindedName.Kind.TYPE_DECL, "UnitTest.I")).getType(), ((UnionType) getTypeOfFirstAssignment(m)).getType(0));
}
Also used : Model(org.abs_models.frontend.ast.Model) KindedName(org.abs_models.frontend.typechecker.KindedName) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 12 with KindedName

use of org.abs_models.frontend.typechecker.KindedName in project abstools by abstools.

the class TypeCheckerTest method classParamsMethodShadowsField.

@Test
public void classParamsMethodShadowsField() {
    Model m = assertParse("class C(Bool b) { Bool m(Bool b) { return b; } }");
    ModuleDecl u = m.lookupModule("UnitTest");
    ClassDecl c = (ClassDecl) u.lookup(new KindedName(KindedName.Kind.CLASS, "C"));
    MethodImpl me = c.lookupMethod("m");
    ReturnStmt r = (ReturnStmt) me.getBlock().getStmt(0);
    VarOrFieldUse vu = (VarOrFieldUse) r.getRetExp();
    ParamDecl d = (ParamDecl) vu.getDecl();
    assertThat(d.getParent().getParent(), instanceOf(MethodSig.class));
    assertThat(vu.getClass().getName(), vu, instanceOf(VarUse.class));
}
Also used : MethodSig(org.abs_models.frontend.ast.MethodSig) ClassDecl(org.abs_models.frontend.ast.ClassDecl) MethodImpl(org.abs_models.frontend.ast.MethodImpl) ParamDecl(org.abs_models.frontend.ast.ParamDecl) Model(org.abs_models.frontend.ast.Model) ModuleDecl(org.abs_models.frontend.ast.ModuleDecl) KindedName(org.abs_models.frontend.typechecker.KindedName) VarUse(org.abs_models.frontend.ast.VarUse) ReturnStmt(org.abs_models.frontend.ast.ReturnStmt) VarOrFieldUse(org.abs_models.frontend.ast.VarOrFieldUse) ABSTest(org.abs_models.ABSTest) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 13 with KindedName

use of org.abs_models.frontend.typechecker.KindedName in project abstools by abstools.

the class VarResolutionTest method testFieldUse.

@Test
public void testFieldUse() {
    Model m = assertParse(" class C { Bool f; Bool m() { return this.f; } }");
    ClassDecl d = (ClassDecl) getTestModule(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, ((FieldUse) s.getRetExp()).getDecl());
}
Also used : VarOrFieldDecl(org.abs_models.frontend.ast.VarOrFieldDecl) 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)

Aggregations

KindedName (org.abs_models.frontend.typechecker.KindedName)13 ClassDecl (org.abs_models.frontend.ast.ClassDecl)10 Model (org.abs_models.frontend.ast.Model)9 Test (org.junit.Test)9 FrontendTest (org.abs_models.frontend.FrontendTest)7 ReturnStmt (org.abs_models.frontend.ast.ReturnStmt)6 ModuleDecl (org.abs_models.frontend.ast.ModuleDecl)5 ABSTest (org.abs_models.ABSTest)3 MethodImpl (org.abs_models.frontend.ast.MethodImpl)3 ParamDecl (org.abs_models.frontend.ast.ParamDecl)3 VarOrFieldUse (org.abs_models.frontend.ast.VarOrFieldUse)3 DeltaDecl (org.abs_models.frontend.ast.DeltaDecl)2 FieldDecl (org.abs_models.frontend.ast.FieldDecl)2 MethodSig (org.abs_models.frontend.ast.MethodSig)2 VarUse (org.abs_models.frontend.ast.VarUse)2 ResolvedName (org.abs_models.frontend.typechecker.ResolvedName)2 Constraint (com.gzoumix.semisolver.constraint.Constraint)1 LinkedList (java.util.LinkedList)1 TypeError (org.abs_models.frontend.analyser.TypeError)1 Annotation (org.abs_models.frontend.ast.Annotation)1