| 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 part of matcher; | 5 part of matcher; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Returns a matcher which matches [Iterable]s in which all elements | 8 * Returns a matcher which matches [Iterable]s in which all elements |
| 9 * match the given [matcher]. | 9 * match the given [matcher]. |
| 10 */ | 10 */ |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 mismatchDescription.add(' at index $index'); | 52 mismatchDescription.add(' at index $index'); |
| 53 return mismatchDescription; | 53 return mismatchDescription; |
| 54 } | 54 } |
| 55 return super.describeMismatch(item, mismatchDescription, | 55 return super.describeMismatch(item, mismatchDescription, |
| 56 matchState, verbose); | 56 matchState, verbose); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * Deprecated form of [anyElement]. |
| 62 */ |
| 63 @deprecated |
| 64 Matcher someElement(matcher) => new _AnyElement(wrapMatcher(matcher)); |
| 65 |
| 66 /** |
| 61 * Returns a matcher which matches [Iterable]s in which at least one | 67 * Returns a matcher which matches [Iterable]s in which at least one |
| 62 * element matches the given [matcher]. | 68 * element matches the given [matcher]. |
| 63 */ | 69 */ |
| 64 Matcher anyElement(matcher) => new _AnyElement(wrapMatcher(matcher)); | 70 Matcher anyElement(matcher) => new _AnyElement(wrapMatcher(matcher)); |
| 65 | 71 |
| 66 class _AnyElement extends _IterableMatcher { | 72 class _AnyElement extends _IterableMatcher { |
| 67 Matcher _matcher; | 73 Matcher _matcher; |
| 68 | 74 |
| 69 _AnyElement(this._matcher); | 75 _AnyElement(this._matcher); |
| 70 | 76 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 iterator.moveNext(); | 224 iterator.moveNext(); |
| 219 if (!_comparator(e, iterator.current)) { | 225 if (!_comparator(e, iterator.current)) { |
| 220 addStateInfo(matchState, {'index': i, 'expected': e, | 226 addStateInfo(matchState, {'index': i, 'expected': e, |
| 221 'actual': iterator.current}); | 227 'actual': iterator.current}); |
| 222 return false; | 228 return false; |
| 223 } | 229 } |
| 224 i++; | 230 i++; |
| 225 } | 231 } |
| 226 return true; | 232 return true; |
| 227 } | 233 } |
| 228 | 234 |
| 229 Description describe(Description description) => | 235 Description describe(Description description) => |
| 230 description.add('pairwise $_description ').addDescriptionOf(_expected); | 236 description.add('pairwise $_description ').addDescriptionOf(_expected); |
| 231 | 237 |
| 232 Description describeMismatch(item, Description mismatchDescription, | 238 Description describeMismatch(item, Description mismatchDescription, |
| 233 Map matchState, bool verbose) { | 239 Map matchState, bool verbose) { |
| 234 if (item is !Iterable) { | 240 if (item is !Iterable) { |
| 235 return mismatchDescription.add('is not an Iterable'); | 241 return mismatchDescription.add('is not an Iterable'); |
| 236 } else if (item.length != _expected.length) { | 242 } else if (item.length != _expected.length) { |
| 237 return mismatchDescription. | 243 return mismatchDescription. |
| 238 add('has length ${item.length} instead of ${_expected.length}'); | 244 add('has length ${item.length} instead of ${_expected.length}'); |
| 239 } else { | 245 } else { |
| 240 return mismatchDescription. | 246 return mismatchDescription. |
| 241 add('has '). | 247 add('has '). |
| 242 addDescriptionOf(matchState["actual"]). | 248 addDescriptionOf(matchState["actual"]). |
| 243 add(' which is not $_description '). | 249 add(' which is not $_description '). |
| 244 addDescriptionOf(matchState["expected"]). | 250 addDescriptionOf(matchState["expected"]). |
| 245 add(' at index ${matchState["index"]}'); | 251 add(' at index ${matchState["index"]}'); |
| 246 } | 252 } |
| 247 } | 253 } |
| 248 } | 254 } |
| 249 | 255 |
| OLD | NEW |