use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class ProgramAbstractionTest method addClass.
@Test
public void addClass() {
Model model = assertParse("module M;" + "delta D;" + "uses M;" + "adds class C(Rat myParam) { Int myField = 99; Int myMethod(String a, Bool b) { return 88; } }" + "productline PL;" + "features F;" + "delta D when F;" + "root FM { group allof { opt F } }");
SemanticConditionList errors = new SemanticConditionList();
ProductLine pl = model.getProductLine();
DeltaTrie trie = ProductLineAnalysisHelper.buildPFGT(pl, errors);
ProgramAbstraction pa = trie.getRoot().getChildren().get("D").getProgramAbstraction();
assertTrue(pa.getClasses().containsKey("M.C"));
assertEquals(2, pa.getClasses().get("M.C").get("fields").keySet().size());
assertTrue(pa.getClasses().get("M.C").get("fields").containsKey("myParam"));
assertEquals("Rat", pa.getClasses().get("M.C").get("fields").get("myParam").get(0));
assertTrue(pa.getClasses().get("M.C").get("fields").containsKey("myField"));
assertEquals("Int", pa.getClasses().get("M.C").get("fields").get("myField").get(0));
assertTrue(pa.getClasses().get("M.C").get("methods").containsKey("myMethod"));
assertEquals(3, pa.getClasses().get("M.C").get("methods").get("myMethod").size());
assertEquals("Int", pa.getClasses().get("M.C").get("methods").get("myMethod").get(0));
assertEquals("String", pa.getClasses().get("M.C").get("methods").get("myMethod").get(1));
assertEquals("Bool", pa.getClasses().get("M.C").get("methods").get("myMethod").get(2));
}
use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class SearchSolutionsTest method SearchSolutions.
@Test
public void SearchSolutions() throws Exception {
Model model = assertParse(helloprogram);
model.setNullPrintStream();
ChocoSolver s = model.instantiateCSModel();
model.evaluateAllProductDeclarations();
assertEquals(78, s.countSolutions());
assertTrue(checkSol(s, model, "P1"));
assertTrue(checkSol(s, model, "P2"));
assertTrue(checkSol(s, model, "P3"));
assertTrue(!checkSol(s, model, "P4"));
}
use of org.abs_models.frontend.ast.Model in project abstools by abstools.
the class SearchSolutionsTest method SearchSolutionsNoAttr.
@Test
public void SearchSolutionsNoAttr() {
Model model = assertParse(helloprogram);
model.dropAttributes();
ChocoSolver s = model.instantiateCSModel();
assertEquals(8, s.countSolutions());
}
use of org.abs_models.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("x__0__", function.getParam(0).getName());
assertEquals("x__1__", function.getParam(1).getName());
}
use of org.abs_models.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