use of org.abs_models.frontend.typechecker.KindedName in project abstools by abstools.
the class AbstractPartialFunctionTest method assertHasFunction.
protected FunctionDecl assertHasFunction(Model model, String regex) {
FunctionDecl result = getFunction(model, Pattern.compile(regex));
String errorMessage = "No expanded function with name " + regex + " created" + " (functions: " + getFunctions(model) + ")";
assertNotNull(errorMessage, result);
Decl decl = model.lookup(new KindedName(KindedName.Kind.FUN, result.getName()));
assertFalse("Could not lookup function " + result.getName(), decl.isUnknown());
return result;
}
use of org.abs_models.frontend.typechecker.KindedName in project abstools by abstools.
the class TypeCheckerTest method classParamsRewrite.
@Test
public void classParamsRewrite() {
Model m = assertParse("class C(Bool b) { Bool m() { 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(ClassDecl.class));
assertThat(vu.getClass().getName(), vu, instanceOf(FieldUse.class));
}
use of org.abs_models.frontend.typechecker.KindedName in project abstools by abstools.
the class TypeCheckerTest method classParamsRewrite2.
@Test
public void classParamsRewrite2() {
Model m = assertParse("class C(Bool b) { Bool m(Bool x) { return x; } }");
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 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());
}
use of org.abs_models.frontend.typechecker.KindedName 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());
}
Aggregations