use of abs.frontend.ast.ClassDecl in project abstools by abstools.
the class OriginalCallTest method targetedAndUntargetedOriginalCall.
@Test
public void targetedAndUntargetedOriginalCall() throws DeltaModellingException {
Model model = assertParseOk("module M;" + "class C { Unit m() {} }" + "delta D1; " + "uses M;" + "modifies class C { adds Unit n() {} }" + "delta D2; " + "uses M;" + "modifies class C { modifies Unit m() { original(); core.original(); } }" + "delta D3; " + "uses M;" + "modifies class C { modifies Unit n() { original(); D1.original(); } }");
DeltaDecl d1 = findDelta(model, "D1");
DeltaDecl d2 = findDelta(model, "D2");
DeltaDecl d3 = findDelta(model, "D3");
// Model.resolveOriginalCalls(new ArrayList<DeltaDecl>(Arrays.asList(d1,d2,d3)));
model.applyDeltas(new ArrayList<>(Arrays.asList(d1, d2, d3)));
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertEquals(cls.getMethods().toString(), 4, cls.getMethods().getNumChild());
assertTrue(cls.getMethod(0).getMethodSig().getName().equals("m"));
assertTrue(cls.getMethod(1).getMethodSig().getName().equals("n"));
assertTrue(cls.getMethod(2).getMethodSig().getName().equals("m$ORIGIN_core"));
assertTrue(cls.getMethod(3).getMethodSig().getName().equals("n$ORIGIN_D1"));
}
use of abs.frontend.ast.ClassDecl in project abstools by abstools.
the class OriginalCallTest method targetedOriginalCall.
@Test
public void targetedOriginalCall() throws DeltaModellingException {
Model model = assertParseOk("module M;" + "class C { Unit m() {} }" + "delta D1;" + "uses M;" + "modifies class C { modifies Unit m() { core.original(); } }" + "adds class C2 { }" + "delta D2;" + "modifies class M.C { modifies Unit m() { D1.original(); } }");
DeltaDecl d1 = findDelta(model, "D1");
DeltaDecl d2 = findDelta(model, "D2");
// Model.resolveOriginalCalls(new ArrayList<DeltaDecl>(Arrays.asList(d1,d2)));
model.applyDeltas(new ArrayList<>(Arrays.asList(d1, d2)));
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertEquals(cls.getMethods().toString(), 3, cls.getMethods().getNumChild());
assertTrue(cls.getMethod(0).getMethodSig().getName().equals("m"));
assertTrue(cls.getMethod(1).getMethodSig().getName().equals("m$ORIGIN_core"));
assertTrue(cls.getMethod(2).getMethodSig().getName().equals("m$ORIGIN_D1"));
}
use of abs.frontend.ast.ClassDecl in project abstools by abstools.
the class OriginalCallTest method multipleTargetedOriginalCalls.
@Test
public void multipleTargetedOriginalCalls() throws DeltaModellingException {
Model model = assertParseOk("module M;" + "class C { }" + "delta D1;" + "uses M;" + "modifies class C { adds Unit m() {} }" + "delta D2;uses M;" + "modifies class C { modifies Unit m() { D1.original(); } }" + "delta D3;uses M;" + "modifies class C { modifies Unit m() { D1.original(); } }");
DeltaDecl d1 = findDelta(model, "D1");
DeltaDecl d2 = findDelta(model, "D2");
DeltaDecl d3 = findDelta(model, "D3");
// Model.resolveOriginalCalls(new ArrayList<DeltaDecl>(Arrays.asList(d1,d2,d3)));
model.applyDeltas(new ArrayList<>(Arrays.asList(d1, d2, d3)));
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertEquals(cls.getMethods().toString(), 2, cls.getMethods().getNumChild());
assertTrue(cls.getMethod(0).getMethodSig().getName().equals("m"));
assertTrue(cls.getMethod(1).getMethodSig().getName().equals("m$ORIGIN_D1"));
}
use of abs.frontend.ast.ClassDecl in project abstools by abstools.
the class OriginalCallTest method multipleCallsToSameMethod.
@Test
public void multipleCallsToSameMethod() throws DeltaModellingException {
Model model = assertParseOk("module M;" + "interface I {}" + "class C implements I { Unit m() {} }" + "delta D;" + "modifies class M.C {" + "modifies Unit m() { original(); original(); }" + "}");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
DeltaDecl delta = findDelta(model, "D");
assertEquals(1, delta.getNumModuleModifier());
model.applyDeltas(new ArrayList<>(Arrays.asList(delta)));
assertEquals(2, cls.getMethods().getNumChild());
// Model.resolveOriginalCalls(new ArrayList<DeltaDecl>(Arrays.asList(delta)));
// assertEquals(delta.getModuleModifiers().toString(),2, delta.getNumModuleModifier());
}
use of abs.frontend.ast.ClassDecl in project abstools by abstools.
the class OriginalCallTest method multipleTargetedOriginalCalls2.
@Test
public void multipleTargetedOriginalCalls2() throws DeltaModellingException {
Model model = assertParseOk("module M;" + "class C { }" + "delta D1;" + "uses M;" + "modifies class C { adds Unit m() {} }" + "delta D2;uses M;" + "modifies class C { modifies Unit m() { D1.original(); } }" + "delta D3;uses M;" + "modifies class C { modifies Unit m() { D1.original(); } }" + "delta D4;uses M;" + "modifies class C { modifies Unit m() { D2.original(); } }");
DeltaDecl d1 = findDelta(model, "D1");
DeltaDecl d2 = findDelta(model, "D2");
DeltaDecl d3 = findDelta(model, "D3");
DeltaDecl d4 = findDelta(model, "D4");
// Model.resolveOriginalCalls(new ArrayList<DeltaDecl>(Arrays.asList(d1,d2,d3)));
model.applyDeltas(new ArrayList<>(Arrays.asList(d1, d2, d3, d4)));
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
assertEquals(cls.getMethods().toString(), 3, cls.getMethods().getNumChild());
assertTrue(cls.getMethod(0).getMethodSig().getName().equals("m"));
assertTrue(cls.getMethod(1).getMethodSig().getName().equals("m$ORIGIN_D1"));
assertTrue(cls.getMethod(2).getMethodSig().getName().equals("m$ORIGIN_D2"));
}
Aggregations