diff options
author | wisberg <wisberg> | 2003-05-14 05:04:49 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2003-05-14 05:04:49 +0000 |
commit | 5599770fed0b787e48efe3c840d12959eaebff3d (patch) | |
tree | aa31df582d7199c5dbe34a1eded980c87c8f4e8c /testing | |
parent | 0544260aeabbb24c8757d341894df4f5148c4ebb (diff) | |
download | aspectj-5599770fed0b787e48efe3c840d12959eaebff3d.tar.gz aspectj-5599770fed0b787e48efe3c840d12959eaebff3d.zip |
- new filter to remove arbitrary elements from diffs
(used to not report unexpected info messages in diffs)
Diffstat (limited to 'testing')
-rw-r--r-- | testing/src/org/aspectj/testing/util/Diffs.java | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/testing/src/org/aspectj/testing/util/Diffs.java b/testing/src/org/aspectj/testing/util/Diffs.java index 7f77afc64..4e493534f 100644 --- a/testing/src/org/aspectj/testing/util/Diffs.java +++ b/testing/src/org/aspectj/testing/util/Diffs.java @@ -13,6 +13,7 @@ package org.aspectj.testing.util; +import java.util.*; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -26,6 +27,11 @@ import org.aspectj.bridge.MessageUtil; /** result struct for expected/actual diffs for Collection */ public class Diffs { + public static final Filter ACCEPT_ALL = new Filter() { + public boolean accept(Object o) { + return true; + } + }; // XXX List -> Collection b/c comparator orders public static final Diffs NONE = new Diffs("NONE", Collections.EMPTY_LIST, Collections.EMPTY_LIST); @@ -50,7 +56,21 @@ public class Diffs { || (0 != this.unexpected.size())); } - public Diffs(String label, List expected, List actual, Comparator comparator) { + public Diffs( + String label, + List expected, + List actual, + Comparator comparator) { + this(label, expected, actual, comparator, ACCEPT_ALL, ACCEPT_ALL); + } + + public Diffs( + String label, + List expected, + List actual, + Comparator comparator, + Filter missingFilter, + Filter unexpectedFilter) { label = label.trim(); if (null == label) { label = ": "; @@ -62,7 +82,21 @@ public class Diffs { ArrayList unexpect = new ArrayList(); org.aspectj.testing.util.LangUtil.makeSoftDiffs(expected, actual, miss, unexpect, comparator); + if (null != missingFilter) { + for (ListIterator iter = miss.listIterator(); iter.hasNext();) { + if (!missingFilter.accept(iter.next())) { + iter.remove(); + } + } + } missing = Collections.unmodifiableList(miss); + if (null != unexpectedFilter) { + for (ListIterator iter = unexpect.listIterator(); iter.hasNext();) { + if (!unexpectedFilter.accept(iter.next())) { + iter.remove(); + } + } + } unexpected = Collections.unmodifiableList(unexpect); different = ((0 != this.missing.size()) || (0 != this.unexpected.size())); @@ -99,5 +133,9 @@ public class Diffs { return label + "(unexpected=" + unexpected.size() + ", missing=" + missing.size() + ")"; } + public static interface Filter { + /** @return true to keep input in list of messages */ + boolean accept(Object input); + } } |