aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authoracolyer <acolyer>2003-11-10 14:45:02 +0000
committeracolyer <acolyer>2003-11-10 14:45:02 +0000
commitd54f21bbd778d29fd2cd1bdbe14402aa7a15551e (patch)
tree277409b52476826a41b8bb364b0c703129649ed8 /testing
parent68c7c68403c074c1c9d8ec735ae57e4a529fee62 (diff)
downloadaspectj-d54f21bbd778d29fd2cd1bdbe14402aa7a15551e.tar.gz
aspectj-d54f21bbd778d29fd2cd1bdbe14402aa7a15551e.zip
expanded definition of makeSoftDiffs to cope with multiple expected
messages on the same line that differ only by message text.
Diffstat (limited to 'testing')
-rw-r--r--testing/src/org/aspectj/testing/util/LangUtil.java117
1 files changed, 71 insertions, 46 deletions
diff --git a/testing/src/org/aspectj/testing/util/LangUtil.java b/testing/src/org/aspectj/testing/util/LangUtil.java
index 6059dcca8..d05fd2edc 100644
--- a/testing/src/org/aspectj/testing/util/LangUtil.java
+++ b/testing/src/org/aspectj/testing/util/LangUtil.java
@@ -944,8 +944,6 @@ public class LangUtil {
ArrayList expected = new ArrayList();
expected.addAll(expectedListIn);
Collections.sort(expected, comparator);
- Iterator expectedIter = expected.iterator();
- Object exp = null;
ArrayList actual = new ArrayList();
actual.addAll(actualListIn);
@@ -953,53 +951,80 @@ public class LangUtil {
Iterator actualIter = actual.iterator();
Object act = null;
- while (((null != act) || actualIter.hasNext())
- && ((null != exp) || expectedIter.hasNext())) {
- if (null == act) {
- act = actualIter.next();
- }
- if (null == exp) {
- exp = expectedIter.next();
- }
- int diff = comparator.compare(exp, act);
- if (0 > diff) { // exp < act
- if (null != missingListOut) {
- missingListOut.add(exp);
- exp = null;
- }
- } else if (0 < diff) { // exp > act
- if (null != extraListOut) {
- extraListOut.add(act);
- act = null;
- }
- } else { // got match of actual to expected
- // absorb all actual matching expected (duplicates)
- while ((0 == diff) && actualIter.hasNext()) {
- act = actualIter.next();
- diff = comparator.compare(exp, act);
- }
- if (0 == diff) {
- act = null;
- }
- exp = null;
- }
+ if (missingListOut != null) {
+ missingListOut.addAll(expectedListIn);
}
- if (null != missingListOut) {
- if (null != exp) {
- missingListOut.add(exp);
- }
- while (expectedIter.hasNext()) {
- missingListOut.add(expectedIter.next());
- }
+ if (extraListOut != null) {
+ extraListOut.addAll(actualListIn);
}
- if (null != extraListOut) {
- if (null != act) {
- extraListOut.add(act);
- }
- while (actualIter.hasNext()) {
- extraListOut.add(actualIter.next());
- }
+
+ // AMC: less efficient, but simplified implementation. Needed since messages can
+ // now match on text content too, and the old algorithm did not cope with two expected
+ // messages on the same line, but with different text content.
+ while (actualIter.hasNext()) {
+ act = actualIter.next();
+ for (Iterator expectedIter = expected.iterator(); expectedIter.hasNext();) {
+ Object exp = expectedIter.next();
+ // if actual matches expected remove actual from extraListOut, and
+ // remove expected from missingListOut
+ int diff = comparator.compare(exp,act);
+ if (diff == 0) {
+ extraListOut.remove(act);
+ missingListOut.remove(exp);
+ } else if (diff > 0) {
+ // since list is sorted, there can be no more matches...
+ break;
+ }
+ }
}
+
+// while (((null != act) || actualIter.hasNext())
+// && ((null != exp) || expectedIter.hasNext())) {
+// if (null == act) {
+// act = actualIter.next();
+// }
+// if (null == exp) {
+// exp = expectedIter.next();
+// }
+// int diff = comparator.compare(exp, act);
+// if (0 > diff) { // exp < act
+// if (null != missingListOut) {
+// missingListOut.add(exp);
+// exp = null;
+// }
+// } else if (0 < diff) { // exp > act
+// if (null != extraListOut) {
+// extraListOut.add(act);
+// act = null;
+// }
+// } else { // got match of actual to expected
+// // absorb all actual matching expected (duplicates)
+// while ((0 == diff) && actualIter.hasNext()) {
+// act = actualIter.next();
+// diff = comparator.compare(exp, act);
+// }
+// if (0 == diff) {
+// act = null;
+// }
+// exp = null;
+// }
+// }
+// if (null != missingListOut) {
+// if (null != exp) {
+// missingListOut.add(exp);
+// }
+// while (expectedIter.hasNext()) {
+// missingListOut.add(expectedIter.next());
+// }
+// }
+// if (null != extraListOut) {
+// if (null != act) {
+// extraListOut.add(act);
+// }
+// while (actualIter.hasNext()) {
+// extraListOut.add(actualIter.next());
+// }
+// }
}
public static class FlattenSpec {
/**