diff --git a/pom.xml b/pom.xml
index 68ddc42..5442faf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,9 +13,9 @@
https://maven.pkg.github.com/spgroup/soot/
- rbonifacio
+ svfa-scala
Temporary repository for the SVFA library
- https://maven.pkg.github.com/rbonifacio/svfa-scala/
+ https://maven.pkg.github.com/spgroup/svfa-scala/
@@ -41,7 +41,7 @@
br.unb.cic
svfa-scala_2.12
- 0.5.9
+ 0.5.10
diff --git a/src/test/java/br/unb/cic/analysis/dfp/DFPAnalysisBaseTest.java b/src/test/java/br/unb/cic/analysis/dfp/DFPAnalysisBaseTest.java
index 8c44c9d..0bbe23e 100644
--- a/src/test/java/br/unb/cic/analysis/dfp/DFPAnalysisBaseTest.java
+++ b/src/test/java/br/unb/cic/analysis/dfp/DFPAnalysisBaseTest.java
@@ -26,7 +26,7 @@ public void configure() {
protected Map> sourceDefinitions() {
Map> res = new HashMap<>();
List lines = new ArrayList<>();
- lines.add(11);
+ lines.add(15);
res.put("br.unb.cic.analysis.samples.DFPBaseSample", lines);
return res;
}
@@ -35,7 +35,7 @@ protected Map> sourceDefinitions() {
protected Map> sinkDefinitions() {
Map> res = new HashMap<>();
List lines = new ArrayList<>();
- lines.add(13);
+ lines.add(17);
res.put("br.unb.cic.analysis.samples.DFPBaseSample", lines);
return res;
diff --git a/src/test/java/br/unb/cic/analysis/dfp/DFPAnalysisMotivantingTest.java b/src/test/java/br/unb/cic/analysis/dfp/DFPAnalysisMotivantingTest.java
new file mode 100644
index 0000000..80c8a38
--- /dev/null
+++ b/src/test/java/br/unb/cic/analysis/dfp/DFPAnalysisMotivantingTest.java
@@ -0,0 +1,56 @@
+package br.unb.cic.analysis.dfp;
+
+import br.unb.cic.analysis.AbstractMergeConflictDefinition;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DFPAnalysisMotivantingTest {
+
+ private DFPAnalysisSemanticConflicts analysis;
+ AbstractMergeConflictDefinition definition;
+ @Before
+ public void configure() {
+ definition = new AbstractMergeConflictDefinition(true) {
+ @Override
+ protected Map> sourceDefinitions() {
+ Map> res = new HashMap<>();
+ List lines = new ArrayList<>();
+ lines.add(9);
+ res.put("br.unb.cic.analysis.samples.DFPMotivating", lines);
+ return res;
+ }
+
+ @Override
+ protected Map> sinkDefinitions() {
+ Map> res = new HashMap<>();
+ List lines = new ArrayList<>();
+ lines.add(11);
+ res.put("br.unb.cic.analysis.samples.DFPMotivating", lines);
+
+ return res;
+ }
+ };
+
+ String cp = "target/test-classes";
+ analysis = new DFPInterProcedural(cp, definition);
+ }
+
+ @Test
+ public void testDFPAnalysisExpectingOneMoreConflict() {
+ analysis.configureSoot();
+
+ analysis.buildDFP();
+ System.out.println(analysis.svg().reportConflicts().size());
+ analysis.reportDFConflicts();
+ System.out.println(analysis.svgToDotModel());
+ System.out.println(analysis.findSourceSinkPaths());
+ System.out.println(analysis.svg().findConflictingPaths());
+ Assert.assertTrue(analysis.svg().reportConflicts().size() == 1);
+ }
+}
diff --git a/src/test/java/br/unb/cic/analysis/samples/DFPBaseSample.java b/src/test/java/br/unb/cic/analysis/samples/DFPBaseSample.java
index ba9c4af..c67d8fa 100644
--- a/src/test/java/br/unb/cic/analysis/samples/DFPBaseSample.java
+++ b/src/test/java/br/unb/cic/analysis/samples/DFPBaseSample.java
@@ -6,15 +6,19 @@
public class DFPBaseSample {
private String text;
+ public DFPBaseSample(String text){
+ this.text = text;
+ }
+
public void cleanText(){
- DFPBaseSample inst = new DFPBaseSample();
+ DFPBaseSample inst = new DFPBaseSample("the the dog");
inst.normalizeWhiteSpace(); //Left
inst.removeComments();
inst.removeDuplicateWords(); //Right
}
private void normalizeWhiteSpace(){
- text.replace(" ", "");
+ text = text.replace(" ", " ");
}
private void removeComments(){
@@ -34,13 +38,13 @@ private void removeComments(){
}
private void removeDuplicateWords(){
- String[] words = text.split(" ");
- StringBuilder result = new StringBuilder(words[0]);
- for (int i = 1; i < words.length; i++) {
- if (!words[i].equals(words[i - 1])) {
- result.append(" ");
+ String[] words = text.split(" ", -1);
+ StringBuilder result = new StringBuilder();
+ for (int i = 0; i < words.length; i++) {
+ if (i == 0 || !words[i].equals(words[i - 1]))
result.append(words[i]);
- }
+ if (i < words.length - 1)
+ result.append(" ");
}
text = result.toString();
diff --git a/src/test/java/br/unb/cic/analysis/samples/DFPMotivating.java b/src/test/java/br/unb/cic/analysis/samples/DFPMotivating.java
new file mode 100644
index 0000000..90b2045
--- /dev/null
+++ b/src/test/java/br/unb/cic/analysis/samples/DFPMotivating.java
@@ -0,0 +1,26 @@
+package br.unb.cic.analysis.samples;
+
+public class DFPMotivating {
+ public String text;
+ public int fixes, comments;
+
+ public void generateReport(){
+ DFPMotivating inst = new DFPMotivating();
+ inst.countDupWhitespace(); //RIGHT
+ inst.countComments();
+ inst.countDupWords(); // LEFT
+ }
+
+ private void countDupWords() {
+ fixes = fixes + 2;
+ }
+
+ private void countComments() {
+ comments = comments +1;
+ }
+
+ private void countDupWhitespace() {
+ fixes = fixes + 1;
+ }
+
+}