use of org.abs_models.frontend.ast.DeltaDecl in project abstools by abstools.
the class OriginalCallTest method oneDeltaMultipleCalls.
@Test
public void oneDeltaMultipleCalls() throws DeltaModellingException {
Model model = assertParse("module M;" + "interface I {}" + "class C implements I { Unit m() {} Unit n() {} Unit p() {} }" + "delta D;uses M;" + "modifies class C {" + "modifies Unit m() { original(); }" + "modifies Unit n() { original(); }" + "modifies Unit p() { 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(6, cls.getMethods().getNumChild());
// Model.resolveOriginalCalls(new ArrayList<DeltaDecl>(Arrays.asList(delta)));
// assertEquals(4, delta.getNumModuleModifier());
}
use of org.abs_models.frontend.ast.DeltaDecl in project abstools by abstools.
the class OriginalCallTest method multipleTargetedOriginalCalls.
@Test
public void multipleTargetedOriginalCalls() throws DeltaModellingException {
Model model = assertParse("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 org.abs_models.frontend.ast.DeltaDecl in project abstools by abstools.
the class OtherAnalysisTests method awaitRewriteDecl1.
@Test
public void awaitRewriteDecl1() {
Model m = assertParse("module A; class C { } delta D; modifies class C { adds Unit m() { return await this!m();}}");
DeltaDecl c = m.getDeltaDecls().iterator().next();
// pity, would like this to work so that size == 0
assertEquals(c.findChildren(AwaitAsyncCall.class).size(), 1);
}
use of org.abs_models.frontend.ast.DeltaDecl in project abstools by abstools.
the class AddImportsTest method addExport.
@Test
public void addExport() throws DeltaModellingException {
Model model = assertParse("module Exporter;" + "interface I {}" + "module M;" + "class C {}" + "delta D1; uses Exporter;" + "adds export I;" + "delta D2; uses M;" + "adds import Exporter.I;" + "modifies class C { adds Exporter.I field1; } ");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
DeltaDecl d1 = findDelta(model, "D1");
DeltaDecl d2 = findDelta(model, "D2");
model.applyDeltas(new ArrayList<>(Arrays.asList(d1, d2)));
ModuleDecl clsmodule = cls.getModuleDecl();
Map<KindedName, ResolvedName> clsVisibleSymbols = clsmodule.getVisibleNames();
KindedName symbol1 = new KindedName(KindedName.Kind.TYPE_DECL, "Exporter.I");
assertTrue(clsVisibleSymbols.containsKey(symbol1));
}
use of org.abs_models.frontend.ast.DeltaDecl in project abstools by abstools.
the class AddImportsTest method addImport.
@Test
public void addImport() throws DeltaModellingException {
Model model = assertParse("module Exporter; export *;" + "interface I {}" + "interface J {}" + "module Exporter2; export *;" + "interface K {}" + "module M;" + "class C {}" + "delta D; uses M;" + "adds import Exporter.I;" + "adds import J from Exporter;" + "adds import * from Exporter2;" + "modifies class C { adds Exporter.I field1; } " + "modifies class C { adds J field2; } " + "modifies class C { adds K field3; } ");
ClassDecl cls = (ClassDecl) findDecl(model, "M", "C");
DeltaDecl delta = findDelta(model, "D");
model.applyDeltas(new ArrayList<>(Arrays.asList(delta)));
ModuleDecl clsmodule = cls.getModuleDecl();
Map<KindedName, ResolvedName> clsVisibleSymbols = clsmodule.getVisibleNames();
KindedName symbol1 = new KindedName(KindedName.Kind.TYPE_DECL, "Exporter.I");
KindedName symbol2 = new KindedName(KindedName.Kind.TYPE_DECL, "J");
KindedName symbol3 = new KindedName(KindedName.Kind.TYPE_DECL, "K");
assertTrue(clsVisibleSymbols.containsKey(symbol1));
assertTrue(clsVisibleSymbols.containsKey(symbol2));
assertTrue(clsVisibleSymbols.containsKey(symbol3));
}
Aggregations