use of org.abs_models.frontend.ast.ParametricFunctionDecl in project abstools by abstools.
the class TypingTest method functionTypeParams.
@Test
public void functionTypeParams() {
Model m = assertParse(" def A f<A>(A a) = a ;");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
assertEquals(d.getTypeParameter(0), ((TypeParameter) ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType()).getDecl());
}
use of org.abs_models.frontend.ast.ParametricFunctionDecl in project abstools by abstools.
the class TypingTest method functionTypeArgs2.
@Test
public void functionTypeArgs2() {
Model m = assertParse(" def Maybe<A> f<A>(Maybe<A> o) = o ;");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
assertEquals(d.getTypeUse().getType(), ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType());
}
use of org.abs_models.frontend.ast.ParametricFunctionDecl in project abstools by abstools.
the class TypingTest method functionTypeArgs5.
@Test
public void functionTypeArgs5() {
Model m = assertParse("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 org.abs_models.frontend.ast.ParametricFunctionDecl in project abstools by abstools.
the class TypingTest method functionTypeArgs.
@Test
public void functionTypeArgs() {
Model m = assertParse(" def Maybe<A> f<A>() = None ;");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
DataTypeType t = (DataTypeType) d.getTypeUse().getType();
TypeParameter typeArg = (TypeParameter) t.getTypeArg(0);
assertEquals(typeArg.getDecl(), d.getTypeParameter(0));
}
use of org.abs_models.frontend.ast.ParametricFunctionDecl in project abstools by abstools.
the class TypingTest method functionTypeArgs4.
@Test
public void functionTypeArgs4() {
Model m = assertParse(" data Foo<A> = Bar(A,Bool); " + "def Bool f<A>(Foo<A> o) = case o { Bar(a,b) => b; } ;");
ParametricFunctionDecl d = getLastParametricFunctionDecl(m);
Type type = ((ExpFunctionDef) d.getFunctionDef()).getRhs().getType();
assertEquals(m.getBoolType(), type);
}
Aggregations