Skip to content

Commit

Permalink
tests(spgroup#31): add main to tests without conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
barbosamaatheus committed Aug 11, 2021
1 parent e0c7264 commit 38b122a
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void chainedMethodCallsConflict() {
public void bothMarkingConflict() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.BothMarkingConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{8}, new int[]{12});
.definition(sampleClassPath, new int[]{9}, new int[]{13});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(1, analysis.getConflicts().size());
Expand Down Expand Up @@ -189,7 +189,7 @@ public void classFieldConflict2() {
public void classFieldNotConflict() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.ClassFieldNotConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{8}, new int[]{10});
.definition(sampleClassPath, new int[]{10}, new int[]{12});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(0, analysis.getConflicts().size());
Expand All @@ -199,7 +199,7 @@ public void classFieldNotConflict() {
public void classFieldNotConflict2() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.ClassFieldNotConflictSample2";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{8}, new int[]{10});
.definition(sampleClassPath, new int[]{10}, new int[]{12});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(0, analysis.getConflicts().size());
Expand All @@ -222,7 +222,7 @@ public void classFieldWithParameterNotConflict() {
public void localVariablesNotConflict() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.LocalVariablesNotConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{6}, new int[]{7});
.definition(sampleClassPath, new int[]{8}, new int[]{9});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(0, analysis.getConflicts().size());
Expand All @@ -232,7 +232,7 @@ public void localVariablesNotConflict() {
public void localVariablesNotConflict2() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.LocalVariablesNotConflictSample2";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{6}, new int[]{7});
.definition(sampleClassPath, new int[]{8}, new int[]{9});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(0, analysis.getConflicts().size());
Expand All @@ -242,7 +242,7 @@ public void localVariablesNotConflict2() {
public void localVariablesWithParameterNotConflict() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.LocalVariablesWithParameterNotConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{6}, new int[]{7});
.definition(sampleClassPath, new int[]{8}, new int[]{9});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(0, analysis.getConflicts().size());
Expand All @@ -264,7 +264,7 @@ public void additionToArrayConflict() {
public void hashmapConflict() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.HashmapConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{12}, new int[]{13});
.definition(sampleClassPath, new int[]{11}, new int[]{12});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(511, analysis.getConflicts().size());
Expand Down Expand Up @@ -305,7 +305,17 @@ public void differentMethodOnIdenticalClass() {
public void localArraysNotConflict() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.LocalArrayNotConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{6}, new int[]{7});
.definition(sampleClassPath, new int[]{8}, new int[]{9});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(0, analysis.getConflicts().size());
}

@Test
public void localArraysRecursiveNotConflict() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.LocalArrayRecursiveNotConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{8}, new int[]{9});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(0, analysis.getConflicts().size());
Expand Down Expand Up @@ -415,7 +425,7 @@ public void threeDepthObjectsConflict() {
public void differentAttributeOnIdenticalClass() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.DifferentAttributeOnIdenticalClassNotConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{13}, new int[]{14});
.definition(sampleClassPath, new int[]{16}, new int[]{17});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(0, analysis.getConflicts().size());
Expand All @@ -425,7 +435,7 @@ public void differentAttributeOnIdenticalClass() {
public void differentClassWithSameAttribute() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.DifferentClassWithSameAttributeNotConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{14}, new int[]{15});
.definition(sampleClassPath, new int[]{16}, new int[]{17});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(0, analysis.getConflicts().size());
Expand All @@ -435,17 +445,17 @@ public void differentClassWithSameAttribute() {
public void sameAttributeOnIdenticalClass() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.SameAttributeOnIdenticalClassConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{13}, new int[]{14});
.definition(sampleClassPath, new int[]{9}, new int[]{10});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(0, analysis.getConflicts().size());
Assert.assertEquals(1, analysis.getConflicts().size());
}

@Test
public void concatMethodsConflict() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.ConcatMethodsConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{10}, new int[]{11});
.definition(sampleClassPath, new int[]{9}, new int[]{10});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(1, analysis.getConflicts().size());
Expand Down Expand Up @@ -505,7 +515,7 @@ public void recursiveMockupConflict() {
public void recursiveMockupNotConflict() {
String sampleClassPath = "br.unb.cic.analysis.samples.ioa.RecursiveMockupNotConflictSample";
AbstractMergeConflictDefinition definition = DefinitionFactory
.definition(sampleClassPath, new int[]{8}, new int[]{10});
.definition(sampleClassPath, new int[]{10}, new int[]{12});
InterproceduralOverrideAssignment analysis = new InterproceduralOverrideAssignment(definition);
configureTest(analysis);
Assert.assertEquals(0, analysis.getConflicts().size());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package br.unb.cic.analysis.samples.ioa;

// Conflict: [left, foo():12] --> [right, foo():12]
// Conflict: [left, foo():13] --> [right, foo():13]
public class BothMarkingConflictSample {
private static int x;
private int x;

public void main() {
foo(); // LEFT
public static void main(String[] args) {
BothMarkingConflictSample m = new BothMarkingConflictSample();
m.foo(); // LEFT
}

private static void foo() {
private void foo() {
x = 1; // RIGHT
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// {left, CallGraphClassImplements<init>():38] --> [right, CallGraphClassImplements.baz():43}]

public class CallGraphSample {
private int[] arr;
private static int[] arr;

public void m() {
public static void main(String[] args) {
CallGraphInterface callGraphInterface = new CallGraphClassImplements(); // LEFT
callGraphInterface.baz(); // RIGHT

Expand All @@ -21,8 +21,8 @@ public void m() {
int y = 1;
}

private void foo() {
this.arr[1] = 1;
private static void foo() {
arr[1] = 1;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class ClassFieldConflictSample {
private int x;

public static void main(String[] args) {
ClassFieldConflictSample m =
new ClassFieldConflictSample();
ClassFieldConflictSample m = new ClassFieldConflictSample();

m.x = 0; // LEFT
m.foo(); // RIGHT
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class ClassFieldConflictSample2 {
private int x;

public static void main(String[] args) {
ClassFieldConflictSample2 m =
new ClassFieldConflictSample2();
ClassFieldConflictSample2 m = new ClassFieldConflictSample2();

m.foo(); // LEFT
m.bar(); // RIGHT
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
public class ClassFieldNotConflictSample {
private int x;

public void m() {
x = 0; // LEFT
base();
foo(); // RIGHT
public static void main(String[] args) {
ClassFieldNotConflictSample m = new ClassFieldNotConflictSample();

m.x = 0; // LEFT
m.base();
m.foo(); // RIGHT
}

private void base() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
public class ClassFieldNotConflictSample2 {
private int x;

public void m() {
foo(); // LEFT
base();
bar(); // RIGHT
public static void main(String[] args) {
ClassFieldNotConflictSample2 m = new ClassFieldNotConflictSample2();

m.foo(); // LEFT
m.base();
m.bar(); // RIGHT
}

private void base() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
public class ConcatMethodsConflictSample {

public static void main(String[] args) {
ConcatMethodsConflictSample m =
new ConcatMethodsConflictSample();
ConcatMethodsConflictSample m = new ConcatMethodsConflictSample();

int x = m.foo() + m.bar(); // LEFT i3 = $i0 + $i1 - x = $stack2 + $stack3
x = x + m.qux(); // RIGHT i4 = i3 + $i2 - x = x + $stack4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ public DifferentAttributeOnIdenticalClassNotConflictSample() {
objectSample2 = new ObjectSample();
}

public void m() {
objectSample1.setFoo(1); // LEFT
objectSample2.setBar(2); // RIGHT
public static void main(String[] args) {
DifferentAttributeOnIdenticalClassNotConflictSample m =
new DifferentAttributeOnIdenticalClassNotConflictSample();

m.objectSample1.setFoo(1); // LEFT
m.objectSample2.setBar(2); // RIGHT
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public DifferentClassWithSameAttributeNotConflictSample() {
objectExample2 = new ObjectExample2();
}

public void m() {
objectExample.setFoo(1); // LEFT
objectExample2.setFoo(2); // RIGHT
public static void main(String[] args) {
DifferentClassWithSameAttributeNotConflictSample m = new DifferentClassWithSameAttributeNotConflictSample();

m.objectExample.setFoo(1); // LEFT
m.objectExample2.setFoo(2); // RIGHT
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Conflict: [left, m():13] --> [right, m():14]
public class HashmapConflictSample {


public void m() {
Map<String, String> hashMap = new HashMap<>();
hashMap.put("Left", "left"); // LEFT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public class IfBranchConflictSample {
private int x;

public static void main() {
IfBranchConflictSample m =
new IfBranchConflictSample();
IfBranchConflictSample m = new IfBranchConflictSample();

m.x = 0; // LEFT
m.foo(); // RIGHT
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

// Not Conflict
public class LocalArrayNotConflictSample {
public void m() {
foo(); // LEFT
bar(); // RIGHT
public static void main(String[] args) {
LocalArrayNotConflictSample m = new LocalArrayNotConflictSample();

m.foo(); // LEFT
m.bar(); // RIGHT
}

private void foo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

// Not Conflict
public class LocalArrayRecursiveNotConflictSample {
public void m() {
foo(); // LEFT
bar(); // RIGHT
public static void main(String[] args) {
LocalArrayRecursiveNotConflictSample m = new LocalArrayRecursiveNotConflictSample();

m.foo(); // LEFT
m.bar(); // RIGHT
}

private void foo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

// Not Conflict
public class LocalVariablesNotConflictSample {
public void m() {
foo(); // LEFT
bar(); // RIGHT
public static void main(String[] args) {
LocalVariablesNotConflictSample m = new LocalVariablesNotConflictSample();

m.foo(); // LEFT
m.bar(); // RIGHT
}

private void foo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

// Not Conflict
public class LocalVariablesNotConflictSample2 {
public void m() {
public static void main(String[] args) {
LocalVariablesNotConflictSample2 m = new LocalVariablesNotConflictSample2();

int x = 0; // LEFT
foo(x); // RIGHT
m.foo(x); // RIGHT

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

// Not Conflict
public class LocalVariablesWithParameterNotConflictSample {
public void m() {
foo(0); // LEFT
bar(1); // RIGHT
public static void main(String[] args) {
LocalVariablesWithParameterNotConflictSample m = new LocalVariablesWithParameterNotConflictSample();

m.foo(0); // LEFT
m.bar(1); // RIGHT
}

private void foo(int a) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ public class RecursiveMockupNotConflictSample {

private int x;

public void m() {
foo(); // LEFT
this.x = 3;
foo(); // Right
public static void main(String[] args) {
RecursiveMockupNotConflictSample m = new RecursiveMockupNotConflictSample();

m.foo(); // LEFT
m.x = 3;
m.foo(); // Right
}

private void foo() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package br.unb.cic.analysis.samples.ioa;

// Not Conflict
// Conflict: [left, setFoo():18] --> [right, setFoo():18]
public class SameAttributeOnIdenticalClassConflictSample {
private TestObject testObject;

public SameAttributeOnIdenticalClassConflictSample() {
testObject = new TestObject();
}
public static void main(String[] args) {
TestObject testObject = new TestObject();

public void m() {
testObject.setFoo(1); // LEFT
testObject.setFoo(2); // RIGHT
}
Expand Down
Loading

0 comments on commit 38b122a

Please sign in to comment.