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