use of org.abs_models.frontend.ast.FunctionDecl 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.ast.FunctionDecl in project abstools by abstools.
the class ParFnAppTest method sameAnonTwiceTwoClosureParams.
@Test
public void sameAnonTwiceTwoClosureParams() {
Model m = testExpand(parse("Int x = 1; test(() => x, () => x)();", "def Int test(f, g)() = f() + g();"), "test_%s_Anon\\d+__");
FunctionDecl function = getFunction(m, Pattern.compile(expandedName("test_%s_Anon\\d+__")));
assertNotNull(function);
assertEquals(2, function.getNumParam());
assertEquals("x__0__", function.getParam(0).getName());
assertEquals("x__1__", function.getParam(1).getName());
}
use of org.abs_models.frontend.ast.FunctionDecl 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);
}
use of org.abs_models.frontend.ast.FunctionDecl in project abstools by abstools.
the class TreeUtilsTest method closestParentIgnoresSelf.
@Test
public void closestParentIgnoresSelf() {
Model model = assertParse("def Int test() = 1;");
FunctionDecl functionDecl = getLastFunctionDecl(model);
assertEquals("test", functionDecl.getName());
FunctionDef functionDef = functionDecl.getFunctionDef();
assertSame(functionDecl, functionDef.closestParent(ASTNode.class));
}
use of org.abs_models.frontend.ast.FunctionDecl in project abstools by abstools.
the class TreeUtilsTest method findChildrenList.
@Test
public void findChildrenList() {
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);
assertEquals(2, children.size());
}
Aggregations