use of abs.frontend.ast.ExpFunctionDef in project abstools by abstools.
the class TypingTest method functionTypeArgs2.
@Test
public void functionTypeArgs2() {
Model m = assertParseOkStdLib(" def Maybe<A> f<A>(Maybe<A> o) = o ;");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
assertEquals(d.getTypeUse().getType(), ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType());
}
use of abs.frontend.ast.ExpFunctionDef in project abstools by abstools.
the class TypingTest method functionTypeArgs5.
@Test
public void functionTypeArgs5() {
Model m = assertParseOkStdLib("def B nth<B>(List<B> list, Int n) = nth(tail(list), n-1) ; ");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
TypeParameterDecl typeParameter = d.getTypeParameter(0);
TypeParameter type = (TypeParameter) ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType();
assertEquals(typeParameter.getName(), type.getDecl().getName());
}
use of abs.frontend.ast.ExpFunctionDef in project abstools by abstools.
the class TypingTest method functionTypeArgs3.
@Test
public void functionTypeArgs3() {
Model m = assertParseOkStdLib(" def A f<A>(Maybe<A> o) = case o { Just(a) => a; } ;");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
TypeParameterDecl typeParameter = d.getTypeParameter(0);
TypeParameter type = (TypeParameter) ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType();
TypeParameterDecl decl = type.getDecl();
assertEquals(typeParameter, decl);
}
use of abs.frontend.ast.ExpFunctionDef in project abstools by abstools.
the class TreeUtilsTest method findChildrenIncludeOnlySelf.
@Test
public void findChildrenIncludeOnlySelf() {
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 -> false);
assertNotNull(children);
List<PureExp> result = children.distinct().collect(Collectors.toList());
assertEquals(1, result.size());
assertTrue(result.contains(exp));
}
use of abs.frontend.ast.ExpFunctionDef in project abstools by abstools.
the class TreeUtilsTest method closestParent.
@Test
public void closestParent() {
Model model = assertParseOkStdLib("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));
}
Aggregations