use of org.abs_models.frontend.ast.Model 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");
}
use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class NullCheckerTests method assertTypeErrors.
@Override
protected SemanticCondition assertTypeErrors(String absCode, Config... config) {
Model m = assertParse(absCode, config);
String msg = "";
m.registerTypeSystemExtension(new NullCheckerExtension(m));
SemanticConditionList l = m.typeCheck();
if (l.containsErrors()) {
msg = l.getFirstError().getMsgWithHint(absCode);
} else if (l.containsWarnings() && isSet(EXPECT_WARNING, config)) {
msg = l.getFirstWarning().getMsgWithHint(absCode);
}
assertEquals(msg, isSet(EXPECT_TYPE_ERROR, config), l.containsErrors());
if (isSet(EXPECT_WARNING, config)) {
assertEquals(msg, isSet(EXPECT_WARNING, config), l.containsWarnings());
}
return l.containsErrors() ? l.getFirstError() : null;
}
use of org.abs_models.frontend.ast.Model 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.ast.Model in project abstools by abstools.
the class TypingTest method functionTypeParams.
@Test
public void functionTypeParams() {
Model m = assertParse(" def A f<A>(A a) = a ;");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
assertEquals(d.getTypeParameter(0), ((TypeParameter) ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType()).getDecl());
}
use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class TypingTest method testInterfaceType.
@Test
public void testInterfaceType() {
Model m = assertParse("interface I { } class C {} { I i = new local C(); I i2 = i; }");
assertEquals(m.lookupModule("UnitTest").getDecl(0).getType(), getTypeOfNthAssignment(m, 2));
}
Aggregations