| 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 24 matching lines...) Expand all Loading... |
| 35 } | 35 } |
| 36 | 36 |
| 37 Description describe(Description description) => | 37 Description describe(Description description) => |
| 38 description.add('every element ').addDescriptionOf(_matcher); | 38 description.add('every element ').addDescriptionOf(_matcher); |
| 39 | 39 |
| 40 Description describeMismatch(item, Description mismatchDescription, | 40 Description describeMismatch(item, Description mismatchDescription, |
| 41 MatchState matchState, bool verbose) { | 41 MatchState matchState, bool verbose) { |
| 42 if (matchState.state != null) { | 42 if (matchState.state != null) { |
| 43 var index = matchState.state['index']; | 43 var index = matchState.state['index']; |
| 44 var element = matchState.state['element']; | 44 var element = matchState.state['element']; |
| 45 mismatchDescription.add('position $index '); | 45 mismatchDescription.add('at position $index '); |
| 46 return _matcher.describeMismatch(element, mismatchDescription, | 46 return _matcher.describeMismatch(element, mismatchDescription, |
| 47 matchState.state['state'], verbose); | 47 matchState.state['state'], verbose); |
| 48 } | 48 } |
| 49 return super.describeMismatch(item, mismatchDescription, | 49 return super.describeMismatch(item, mismatchDescription, |
| 50 matchState, verbose); | 50 matchState, verbose); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Returns a matcher which matches [Iterable]s in which at least one | 55 * Returns a matcher which matches [Iterable]s in which at least one |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 bool matches(item, MatchState matchState) => | 89 bool matches(item, MatchState matchState) => |
| 90 (item is Iterable) && _matcher.matches(item, matchState); | 90 (item is Iterable) && _matcher.matches(item, matchState); |
| 91 | 91 |
| 92 Description describe(Description description) => | 92 Description describe(Description description) => |
| 93 description.add('equals ').addDescriptionOf(_expected).add(' ordered'); | 93 description.add('equals ').addDescriptionOf(_expected).add(' ordered'); |
| 94 | 94 |
| 95 Description describeMismatch(item, Description mismatchDescription, | 95 Description describeMismatch(item, Description mismatchDescription, |
| 96 MatchState matchState, bool verbose) { | 96 MatchState matchState, bool verbose) { |
| 97 if (item is !Iterable) { | 97 if (item is !Iterable) { |
| 98 return mismatchDescription.add('not an Iterable'); | 98 return mismatchDescription.add('is not an Iterable'); |
| 99 } else { | 99 } else { |
| 100 return _matcher.describeMismatch(item, mismatchDescription, | 100 return _matcher.describeMismatch(item, mismatchDescription, |
| 101 matchState, verbose); | 101 matchState, verbose); |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 /** | 105 /** |
| 106 * Returns a matcher which matches [Iterable]s that have the same | 106 * Returns a matcher which matches [Iterable]s that have the same |
| 107 * length and the same elements as [expected], but not necessarily in | 107 * length and the same elements as [expected], but not necessarily in |
| 108 * the same order. Note that this is O(n^2) so should only be used on | 108 * the same order. Note that this is O(n^2) so should only be used on |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 223 } |
| 224 return true; | 224 return true; |
| 225 } | 225 } |
| 226 | 226 |
| 227 Description describe(Description description) => | 227 Description describe(Description description) => |
| 228 description.add('pairwise $_description ').addDescriptionOf(_expected); | 228 description.add('pairwise $_description ').addDescriptionOf(_expected); |
| 229 | 229 |
| 230 Description describeMismatch(item, Description mismatchDescription, | 230 Description describeMismatch(item, Description mismatchDescription, |
| 231 MatchState matchState, bool verbose) { | 231 MatchState matchState, bool verbose) { |
| 232 if (item is !Iterable) { | 232 if (item is !Iterable) { |
| 233 return mismatchDescription.add('not an Iterable'); | 233 return mismatchDescription.add('is not an Iterable'); |
| 234 } else if (item.length != _expected.length) { | 234 } else if (item.length != _expected.length) { |
| 235 return mismatchDescription. | 235 return mismatchDescription. |
| 236 add('length was ${item.length} instead of ${_expected.length}'); | 236 add('has length ${item.length} instead of ${_expected.length}'); |
| 237 } else { | 237 } else { |
| 238 return mismatchDescription. | 238 return mismatchDescription. |
| 239 add('has '). |
| 239 addDescriptionOf(matchState.state["actual"]). | 240 addDescriptionOf(matchState.state["actual"]). |
| 240 add(' not $_description '). | 241 add(' which is not $_description '). |
| 241 addDescriptionOf(matchState.state["expected"]). | 242 addDescriptionOf(matchState.state["expected"]). |
| 242 add(' at position ${matchState.state["index"]}'); | 243 add(' at position ${matchState.state["index"]}'); |
| 243 } | 244 } |
| 244 } | 245 } |
| 245 } | 246 } |
| 246 | 247 |
| OLD | NEW |