use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProductDeclarationTest method undeclaredProduct.
// FIXME: The correct error message is emitted, but via throwing an
// exception instead of reporting it in the condition list. Additionally,
// the WrongProgramArgumentException is re-thrown as a RuntimeException.
// The proper fix is to just add an error to the SemanticConditionList
// instead of throwing an exception
// @Test(expected=org.abs_models.common.WrongProgramArgumentException.class)
@Test(expected = java.lang.RuntimeException.class)
public void undeclaredProduct() throws WrongProgramArgumentException {
Model model = assertParse("product P1 = P2 && P3 || P4 || {F1, F2};");
ProductDecl p = model.findProduct("P1");
SemanticConditionList e = new SemanticConditionList();
typeCheck(model, p, e);
assertEquals(3, e.getErrorCount());
Assert.assertEquals(ErrorMessage.UNDECLARED_PRODUCT, e.getFirstError().msg);
}
use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class ProgramAbstractionTest method core.
@Test
public void core() {
Model model = assertParse("module M;" + "class C(Rat myParam) { Int myField = 99; Int myMethod(String a, Bool b) { return 88; } }" + "productline PL;" + "features F;");
SemanticConditionList errors = new SemanticConditionList();
ProductLine pl = model.getProductLine();
DeltaTrie trie = ProductLineAnalysisHelper.buildPFGT(pl, errors);
ProgramAbstraction pa = trie.getRoot().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