use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProductDeclarationTest method validProduct.
@Test
public void validProduct() throws WrongProgramArgumentException {
Model model = assertParseOk("product P1 = {F1, F2, F3};" + "root FM {" + "group allof { F1, F2, F3 }" + "}");
model.evaluateAllProductDeclarations();
ProductDecl p = model.findProduct("P1");
SemanticConditionList e = new SemanticConditionList();
typeCheck(model, p, e);
assertEquals(0, e.getErrorCount());
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine6.
@Test
public void stronglyUnambiguousProductLine6() {
Model model = assertParseOk("module M;" + "delta D1; uses M; modifies class C { adds Unit foo() {} }" + "delta D2; uses M; removes class C;" + "delta D3; uses M; adds class C {}" + "productline PL;" + "features A;" + "delta D1;" + "delta D2;" + "delta D3;");
ProductLine pl = model.getProductLine();
SemanticConditionList errors = new SemanticConditionList();
/* All 3 deltas are in same partition
* D1, D2, D3 act on the same class C
*/
assertFalse(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
assertEquals(2, errors.getErrorCount());
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProductLineTypeAnalysisTest method stronglyUnambiguousProductLine4.
@Test
public void stronglyUnambiguousProductLine4() {
Model model = assertParseOk("module M;" + "delta D1; uses M; modifies class C { adds Unit foo() {} }" + "delta D2; uses M; modifies class C { adds Unit foo() {} }" + "productline PL;" + "features A;" + "delta D1;" + "delta D2;");
ProductLine pl = model.getProductLine();
SemanticConditionList errors = new SemanticConditionList();
/* Both deltas are in same partition (no order specified)
* Both deltas modify the same method C.foo
*/
assertFalse(ProductLineAnalysisHelper.isStronglyUnambiguous(pl, errors));
assertEquals(1, errors.getErrorCount());
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProgramAbstractionTest method removeClass.
@Test
public void removeClass() {
Model model = assertParseOk("module M;" + "class C(Rat myParam) { Int myField = 99; Int myMethod(String a, Bool b) { return 88; } }" + "delta D;" + "uses M;" + "removes class C;" + "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();
System.out.println("******\n" + pa);
assertFalse(pa.getClasses().containsKey("M.C"));
}
use of abs.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProgramAbstractionTest method addClass.
@Test
public void addClass() {
Model model = assertParseOk("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));
}
Aggregations