use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class TypeCheckerTest method ticket414_futNeedsDataType1.
@Test
public void ticket414_futNeedsDataType1() {
Model m = assertParse("module M; interface I {} { Fut<I> fi; }");
assertFalse(m.hasErrors());
Block b = m.getMainBlock();
assertNotNull(b);
VarDeclStmt s = (VarDeclStmt) b.getStmt(0);
ParametricDataTypeUse u = (ParametricDataTypeUse) s.getVarDecl().getTypeUse();
// Have:
TypeUse tu = u.getParam(0);
assertEquals("I", tu.getName());
assertThat(tu, instanceOf(InterfaceTypeUse.class));
assertThat(tu.getType(), instanceOf(InterfaceType.class));
assertThat(tu.getDecl(), instanceOf(InterfaceDecl.class));
}
use of org.abs_models.frontend.ast.Model 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.ast.Model in project abstools by abstools.
the class TypeCheckerTest method test_Movecogto1.
@Test
public void test_Movecogto1() {
Model m = assertParse("class C { Unit do() { movecogto 1; }}");
SemanticConditionList errs = m.typeCheck();
assertTrue(m.hasTypeErrors());
Assert.assertEquals(ErrorMessage.EXPECTED_DC, errs.getFirstError().msg);
}
use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class TypeCheckerTest method ticket414_futNeedsDataType2.
@Test
public void ticket414_futNeedsDataType2() {
Model m = assertParse("module M; data I = I; { Fut<I> fi; }");
assertFalse(m.hasErrors());
Block b = m.getMainBlock();
assertNotNull(b);
VarDeclStmt s = (VarDeclStmt) b.getStmt(0);
ParametricDataTypeUse u = (ParametricDataTypeUse) s.getVarDecl().getTypeUse();
// Have:
TypeUse tu = u.getParam(0);
assertEquals("I", tu.getName());
assertThat(tu, instanceOf(DataTypeUse.class));
}
use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class TreeUtilsTest method findChildrenListLazy.
@Test
public void findChildrenListLazy() {
Model model = assertParse("def Int test(Int i) = test(1);");
FunctionDecl functionDecl = getLastFunctionDecl(model);
assertEquals("test", functionDecl.getName());
List<PureExp> children = functionDecl.getFunctionDef().findChildren(PureExp.class, true);
assertEquals(1, children.size());
assertTrue(children.get(0) instanceof FnApp);
}
Aggregations