Search in sources :

Example 66 with ClassDecl

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

Example 67 with ClassDecl

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

Example 68 with ClassDecl

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

Example 69 with ClassDecl

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

Example 70 with ClassDecl

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

Aggregations

ClassDecl (abs.frontend.ast.ClassDecl)75 Test (org.junit.Test)59 Model (abs.frontend.ast.Model)57 DeltaDecl (abs.frontend.ast.DeltaDecl)22 FrontendTest (abs.frontend.FrontendTest)12 ModifyClassModifier (abs.frontend.ast.ModifyClassModifier)12 SkipStmt (abs.frontend.ast.SkipStmt)11 DeltaTraitModifier (abs.frontend.ast.DeltaTraitModifier)7 InterfaceDecl (abs.frontend.ast.InterfaceDecl)7 MethodImpl (abs.frontend.ast.MethodImpl)7 ModifyMethodModifier (abs.frontend.ast.ModifyMethodModifier)7 TraitExpr (abs.frontend.ast.TraitExpr)7 MethodSig (abs.frontend.ast.MethodSig)6 ReturnStmt (abs.frontend.ast.ReturnStmt)6 AddMethodModifier (abs.frontend.ast.AddMethodModifier)5 Decl (abs.frontend.ast.Decl)5 DeltaAccess (abs.frontend.ast.DeltaAccess)5 List (abs.frontend.ast.List)5 TraitSetExpr (abs.frontend.ast.TraitSetExpr)5 CompilationUnit (abs.frontend.ast.CompilationUnit)4