Search in sources :

Example 6 with ExpFunctionDef

use of abs.frontend.ast.ExpFunctionDef in project abstools by abstools.

the class TreeUtilsTest method findChildrenIncludeSelf.

@Test
public void findChildrenIncludeSelf() {
    Model model = assertParseOkStdLib("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 -> true);
    assertNotNull(children);
    List<PureExp> result = children.distinct().collect(Collectors.toList());
    assertEquals(2, result.size());
    assertTrue(result.contains(exp));
}
Also used : Model(abs.frontend.ast.Model) PureExp(abs.frontend.ast.PureExp) FunctionDecl(abs.frontend.ast.FunctionDecl) ExpFunctionDef(abs.frontend.ast.ExpFunctionDef) Test(org.junit.Test) FrontendTest(abs.frontend.FrontendTest)

Aggregations

FrontendTest (abs.frontend.FrontendTest)6 ExpFunctionDef (abs.frontend.ast.ExpFunctionDef)6 Model (abs.frontend.ast.Model)6 Test (org.junit.Test)6 FunctionDecl (abs.frontend.ast.FunctionDecl)3 ParametricFunctionDecl (abs.frontend.ast.ParametricFunctionDecl)3 PureExp (abs.frontend.ast.PureExp)3 TypeParameterDecl (abs.frontend.ast.TypeParameterDecl)2 TypeParameter (abs.frontend.typechecker.TypeParameter)2 Decl (abs.frontend.ast.Decl)1