Index: pkg/matcher/lib/src/operator_matchers.dart |
diff --git a/pkg/matcher/lib/src/operator_matchers.dart b/pkg/matcher/lib/src/operator_matchers.dart |
index fb79e8fd2586474814893b8e0760103885a15e2a..a6d23c21068179d6287e6011bcc2e23385a2b052 100644 |
--- a/pkg/matcher/lib/src/operator_matchers.dart |
+++ b/pkg/matcher/lib/src/operator_matchers.dart |
@@ -4,9 +4,8 @@ |
library matcher.operator_matchers; |
-import 'core_matchers.dart'; |
-import 'expect.dart'; |
import 'interfaces.dart'; |
+import 'util.dart'; |
/// This returns a matcher that inverts [matcher] to its logical negation. |
Matcher isNot(matcher) => new _IsNot(wrapMatcher(matcher)); |
@@ -14,7 +13,7 @@ Matcher isNot(matcher) => new _IsNot(wrapMatcher(matcher)); |
class _IsNot extends Matcher { |
final Matcher _matcher; |
- const _IsNot(Matcher this._matcher); |
+ const _IsNot(this._matcher); |
bool matches(item, Map matchState) => !_matcher.matches(item, matchState); |
@@ -103,40 +102,21 @@ class _AnyOf extends Matcher { |
} |
List<Matcher> _wrapArgs(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { |
+ Iterable<Matcher> matchers; |
if (arg0 is List) { |
- // TODO(kevmoo) throw a more helpful error here if any of these args is |
- // not null |
- expect(arg1, isNull); |
- expect(arg2, isNull); |
- expect(arg3, isNull); |
- expect(arg4, isNull); |
- expect(arg5, isNull); |
- expect(arg6, isNull); |
- |
- return arg0.map((a) => wrapMatcher(a)).toList(); |
- } |
+ if (arg1 != null || arg2 != null || arg3 != null || arg4 != null || |
+ arg5 != null || arg6 != null) { |
+ throw new ArgumentError('If arg0 is a List, all other arguments must be' |
+ ' null.'); |
+ } |
- List matchers = new List(); |
- if (arg0 != null) { |
- matchers.add(wrapMatcher(arg0)); |
- } |
- if (arg1 != null) { |
- matchers.add(wrapMatcher(arg1)); |
- } |
- if (arg2 != null) { |
- matchers.add(wrapMatcher(arg2)); |
- } |
- if (arg3 != null) { |
- matchers.add(wrapMatcher(arg3)); |
+ matchers = arg0; |
+ } else { |
+ matchers = [arg0, arg1, arg2, arg3, arg4, arg5, arg6] |
+ .where((e) => e != null); |
} |
- if (arg4 != null) { |
- matchers.add(wrapMatcher(arg4)); |
- } |
- if (arg5 != null) { |
- matchers.add(wrapMatcher(arg5)); |
- } |
- if (arg6 != null) { |
- matchers.add(wrapMatcher(arg6)); |
- } |
- return matchers; |
+ |
+ return matchers |
+ .map((e) => wrapMatcher(e)) |
+ .toList(); |
} |