use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class TreeUtilsTest method closestParent.
@Test
public void closestParent() {
Model model = assertParse("def Int test() = 1;");
FunctionDecl functionDecl = getLastFunctionDecl(model);
assertEquals("test", functionDecl.getName());
PureExp exp = ((ExpFunctionDef) functionDecl.getFunctionDef()).getRhs();
assertSame(functionDecl, exp.closestParent(Decl.class));
assertSame(functionDecl, exp.closestParent(FunctionDecl.class));
}
use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class TreeUtilsTest method findChildrenIncludeOnlySelf.
@Test
public void findChildrenIncludeOnlySelf() {
Model model = assertParse("def Int test(Int i) = test(1);");
FunctionDecl functionDecl = getLastFunctionDecl(model);
assertEquals("test", functionDecl.getName());
ExpFunctionDef def = (ExpFunctionDef) functionDecl.getFunctionDef();
PureExp exp = def.getRhs();
Stream<PureExp> children = def.findChildren(cast(PureExp.class), n -> false);
assertNotNull(children);
List<PureExp> result = children.distinct().collect(Collectors.toList());
assertEquals(1, result.size());
assertTrue(result.contains(exp));
}
use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class AnnotationTests method testFieldDecl.
@Test
public void testFieldDecl() {
Model m = assertParseOkAnn("class C { [Far] I i; }");
ClassDecl decl = getFirstClassDecl(m);
assertHasLocAnnotation(decl.getField(0).getType(), "Far");
}
use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class AnnotationTests method testMethodParam.
@Test
public void testMethodParam() {
Model m = assertParseOkAnn("class C { Unit m([Far] I i) { } }");
ClassDecl decl = getFirstClassDecl(m);
assertHasLocAnnotation(decl.getMethod(0).getMethodSig().getParam(0).getType(), "Far");
}
use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class AnnotationTests method testVarDecl.
@Test
public void testVarDecl() {
Model m = assertParseOkAnn("{ [Near] I i; }");
VarDeclStmt v = ((VarDeclStmt) m.getMainBlock().getStmt(0));
assertHasLocAnnotation(v.getVarDecl().getType(), "Near");
}
Aggregations