| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library matcher.operator_matchers; | |
| 6 | |
| 7 import 'interfaces.dart'; | 5 import 'interfaces.dart'; |
| 8 import 'util.dart'; | 6 import 'util.dart'; |
| 9 | 7 |
| 10 /// This returns a matcher that inverts [matcher] to its logical negation. | 8 /// This returns a matcher that inverts [matcher] to its logical negation. |
| 11 Matcher isNot(matcher) => new _IsNot(wrapMatcher(matcher)); | 9 Matcher isNot(matcher) => new _IsNot(wrapMatcher(matcher)); |
| 12 | 10 |
| 13 class _IsNot extends Matcher { | 11 class _IsNot extends Matcher { |
| 14 final Matcher _matcher; | 12 final Matcher _matcher; |
| 15 | 13 |
| 16 const _IsNot(this._matcher); | 14 const _IsNot(this._matcher); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 82 } |
| 85 } | 83 } |
| 86 return false; | 84 return false; |
| 87 } | 85 } |
| 88 | 86 |
| 89 Description describe(Description description) => | 87 Description describe(Description description) => |
| 90 description.addAll('(', ' or ', ')', _matchers); | 88 description.addAll('(', ' or ', ')', _matchers); |
| 91 } | 89 } |
| 92 | 90 |
| 93 List<Matcher> _wrapArgs(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { | 91 List<Matcher> _wrapArgs(arg0, arg1, arg2, arg3, arg4, arg5, arg6) { |
| 94 Iterable<Matcher> matchers; | 92 Iterable args; |
| 95 if (arg0 is List) { | 93 if (arg0 is List) { |
| 96 if (arg1 != null || | 94 if (arg1 != null || |
| 97 arg2 != null || | 95 arg2 != null || |
| 98 arg3 != null || | 96 arg3 != null || |
| 99 arg4 != null || | 97 arg4 != null || |
| 100 arg5 != null || | 98 arg5 != null || |
| 101 arg6 != null) { | 99 arg6 != null) { |
| 102 throw new ArgumentError('If arg0 is a List, all other arguments must be' | 100 throw new ArgumentError('If arg0 is a List, all other arguments must be' |
| 103 ' null.'); | 101 ' null.'); |
| 104 } | 102 } |
| 105 | 103 |
| 106 matchers = arg0; | 104 args = arg0; |
| 107 } else { | 105 } else { |
| 108 matchers = | 106 args = [arg0, arg1, arg2, arg3, arg4, arg5, arg6].where((e) => e != null); |
| 109 [arg0, arg1, arg2, arg3, arg4, arg5, arg6].where((e) => e != null); | |
| 110 } | 107 } |
| 111 | 108 |
| 112 return matchers.map((e) => wrapMatcher(e)).toList(); | 109 return args.map((e) => wrapMatcher(e)).toList(); |
| 113 } | 110 } |
| OLD | NEW |