use of abs.frontend.ast.Model in project abstools by abstools.
the class DeltaSamplesTest method test_P2P_P4.
/* @Test
public void test_P2P_P3() throws Exception {
Model m = assertTypeCheckFileOk("tests/abssamples/deltas/PeerToPeer.abs", true);
m.setNullPrintStream();
thrown.expect(DeltaModellingWithNodeException.class);
m.flattenForProduct("P3");
}
*/
@Test
public void test_P2P_P4() throws Exception {
Model m = assertParseFileOk("tests/abssamples/deltas/PeerToPeer.abs", true);
m.setNullPrintStream();
m.flattenForProduct("P4");
m.flushCache();
SemanticConditionList res = m.typeCheck();
if (res.containsErrors())
fail(res.getFirstError().getMessage());
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class DeltaSamplesTest method test_ticket324_A.
@Test
@Ignore("https://github.com/abstools/abstools/issues/193")
public void test_ticket324_A() throws Exception {
Model m = assertParseFileOk("tests/abssamples/deltas/bug324.abs", true);
m.flattenForProduct("A");
m.flushCache();
assertFalse(m.hasTypeErrors());
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class DeltaTrieTest method trieStructure1.
@Test
public void trieStructure1() {
Model model = assertParseOk("module Test;" + "delta D1;" + "delta D2;" + "productline PL;" + "features A,B;" + "delta D1 after D2 when A;" + "delta D2 when B;" + "root FM {" + " group [0..*] { A, B }" + "}");
ProductLine pl = model.getProductLine();
DeltaTrie pfgt = ProductLineAnalysisHelper.buildPFGT(pl, new SemanticConditionList());
// System.out.println(pfgt.toString());
assertTrue(pfgt.getRoot().isValidProduct());
assertEquals(2, pfgt.getRoot().getChildren().size());
assertTrue(pfgt.getRoot().getChildren().get("D1").isValidProduct());
assertTrue(pfgt.getRoot().getChildren().get("D2").isValidProduct());
assertEquals(0, pfgt.getRoot().getChildren().get("D1").getChildren().size());
assertEquals(1, pfgt.getRoot().getChildren().get("D2").getChildren().size());
assertTrue(pfgt.getRoot().getChildren().get("D2").getChildren().get("D1").isValidProduct());
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class DeltaTrieTest method trieStructure2.
@Test
public void trieStructure2() {
Model model = assertParseOk("module Test;" + "delta D1;" + "delta D2;" + "delta D3;" + "productline PL;" + "features A,B,C;" + "delta D1 when A;" + "delta D2 after D1 when B;" + "delta D3 after D2 when C;" + "root FM {" + " group [0..*] { A, B, C }" + "}");
ProductLine pl = model.getProductLine();
DeltaTrie pfgt = ProductLineAnalysisHelper.buildPFGT(pl, new SemanticConditionList());
assertTrue(pfgt.getRoot().isValidProduct());
assertEquals(3, pfgt.getRoot().getChildren().size());
assertTrue(pfgt.getRoot().getChildren().get("D1").isValidProduct());
assertTrue(pfgt.getRoot().getChildren().get("D2").isValidProduct());
assertTrue(pfgt.getRoot().getChildren().get("D3").isValidProduct());
assertEquals(2, pfgt.getRoot().getChildren().get("D1").getChildren().size());
assertEquals(1, pfgt.getRoot().getChildren().get("D2").getChildren().size());
assertEquals(0, pfgt.getRoot().getChildren().get("D3").getChildren().size());
assertTrue(pfgt.getRoot().getChildren().get("D1").getChildren().get("D2").isValidProduct());
assertTrue(pfgt.getRoot().getChildren().get("D1").getChildren().get("D3").isValidProduct());
assertTrue(pfgt.getRoot().getChildren().get("D2").getChildren().get("D3").isValidProduct());
}
use of abs.frontend.ast.Model in project abstools by abstools.
the class OriginalCallTest method originalCall3.
@Test
public void originalCall3() throws DeltaModellingException {
Model model = assertParseOk("module M;" + "interface I {}" + "class C implements I { Int one() { return 1; } }" + "delta D; uses M;" + "modifies class C { modifies Int one() { Int x = original(); return x + 1; } }");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertEquals(1, cls.getMethods().getNumChild());
DeltaDecl delta1 = findDelta(model, "D");
// Model.resolveOriginalCalls(new ArrayList<DeltaDecl>(Arrays.asList(delta1)));
model.applyDeltas(new ArrayList<>(Arrays.asList(delta1)));
assertEquals(2, cls.getMethods().getNumChild());
assertTrue(cls.getMethod(0).getMethodSig().getName().equals("one"));
// make sure method has the right body
assertTrue(cls.getMethod(0).getBlock().getStmt(1) instanceof ReturnStmt);
assertTrue(cls.getMethod(1).getMethodSig().getName().equals("one$ORIGIN_core"));
// make sure method has the right body
assertTrue(cls.getMethod(1).getBlock().getStmt(0) instanceof ReturnStmt);
}
Aggregations