Search in sources :

Example 11 with DeltaDecl

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());
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) DeltaDecl(org.abs_models.frontend.ast.DeltaDecl) Test(org.junit.Test)

Example 12 with DeltaDecl

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"));
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) DeltaDecl(org.abs_models.frontend.ast.DeltaDecl) Test(org.junit.Test)

Example 13 with DeltaDecl

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);
}
Also used : Model(org.abs_models.frontend.ast.Model) DeltaDecl(org.abs_models.frontend.ast.DeltaDecl) FrontendTest(org.abs_models.frontend.FrontendTest) Test(org.junit.Test)

Example 14 with DeltaDecl

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));
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) ModuleDecl(org.abs_models.frontend.ast.ModuleDecl) ResolvedName(org.abs_models.frontend.typechecker.ResolvedName) KindedName(org.abs_models.frontend.typechecker.KindedName) DeltaDecl(org.abs_models.frontend.ast.DeltaDecl) Test(org.junit.Test)

Example 15 with DeltaDecl

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));
}
Also used : ClassDecl(org.abs_models.frontend.ast.ClassDecl) Model(org.abs_models.frontend.ast.Model) ModuleDecl(org.abs_models.frontend.ast.ModuleDecl) ResolvedName(org.abs_models.frontend.typechecker.ResolvedName) KindedName(org.abs_models.frontend.typechecker.KindedName) DeltaDecl(org.abs_models.frontend.ast.DeltaDecl) Test(org.junit.Test)

Aggregations

DeltaDecl (org.abs_models.frontend.ast.DeltaDecl)36 Test (org.junit.Test)35 Model (org.abs_models.frontend.ast.Model)34 ClassDecl (org.abs_models.frontend.ast.ClassDecl)24 ModifyClassModifier (org.abs_models.frontend.ast.ModifyClassModifier)13 DeltaTraitModifier (org.abs_models.frontend.ast.DeltaTraitModifier)8 ModifyMethodModifier (org.abs_models.frontend.ast.ModifyMethodModifier)7 TraitExpr (org.abs_models.frontend.ast.TraitExpr)7 AddMethodModifier (org.abs_models.frontend.ast.AddMethodModifier)5 TraitSetExpr (org.abs_models.frontend.ast.TraitSetExpr)5 CompilationUnit (org.abs_models.frontend.ast.CompilationUnit)4 FrontendTest (org.abs_models.frontend.FrontendTest)3 DataTypeDecl (org.abs_models.frontend.ast.DataTypeDecl)3 Decl (org.abs_models.frontend.ast.Decl)3 DeltaAccess (org.abs_models.frontend.ast.DeltaAccess)3 FunctionDecl (org.abs_models.frontend.ast.FunctionDecl)3 List (org.abs_models.frontend.ast.List)3 MethodSig (org.abs_models.frontend.ast.MethodSig)3 ParametricDataTypeDecl (org.abs_models.frontend.ast.ParametricDataTypeDecl)3 TypeSynDecl (org.abs_models.frontend.ast.TypeSynDecl)3