use of abs.frontend.ast.Model in project abstools by abstools.
the class SearchSolutionsTest method CheckEmptyProduct.
@Test
public void CheckEmptyProduct() throws WrongProgramArgumentException {
Model model = assertParseOk(withoutProducLine);
ChocoSolver s = model.instantiateCSModel();
model.evaluateAllProductDeclarations();
ProductDecl product = model.findProduct("P");
Map<String, Integer> guess = product.getProduct().getSolution();
assertEquals(true, s.checkSolution(guess, model));
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class ParFnAppTest method tooManyArgsForFuncParam.
@Test
public void tooManyArgsForFuncParam() {
Model m = parse("apply(tooFew)(0);", applyFunction(), "def Int tooFew() = 0;");
m.expandPartialFunctions();
SemanticConditionList conditions = m.typeCheck();
assertTrue(conditions.containsErrors());
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class ParFnAppTest method sameAnonTwiceTwoExpansions.
@Test
public void sameAnonTwiceTwoExpansions() {
Model m = testExpand(parse("apply((Int i) => i)(1);" + "apply((Int i) => i)(1);", applyFunction()));
ModuleDecl module = m.lookupModule("UnitTest");
int foundExpansions = 0;
for (Decl decl : module.getDecls()) {
if (decl instanceof FunctionDecl) {
FunctionDecl fun = (FunctionDecl) decl;
if (fun.getName().startsWith("Apply_")) {
++foundExpansions;
}
}
}
assertEquals(2, foundExpansions);
}
use of abs.frontend.ast.Model 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("X0", function.getParam(0).getName());
assertEquals("X1", function.getParam(1).getName());
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class ParFnAppTest method recursionWithClosure.
@Test
public void recursionWithClosure() {
Model m = expand(parse("Int x = 0; Int y = 1; rec((Int i) => x, (Int j) => y)();", "def Int rec(f, g)() = rec();"));
FnApp call = assertHasCall(m, expandedName("Rec_%s_Anon\\d+"));
assertEquals(2, call.getNumParam());
}
Aggregations