| 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 /** | 5 /** |
| 6 * Returns a matcher which matches [Collection]s in which all elements | 6 * Returns a matcher which matches [Collection]s in which all elements |
| 7 * match the given [matcher]. | 7 * match the given [matcher]. |
| 8 */ | 8 */ |
| 9 Matcher everyElement(matcher) => new _EveryElement(wrapMatcher(matcher)); | 9 Matcher everyElement(matcher) => new _EveryElement(wrapMatcher(matcher)); |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 for (var element in item) { | 100 for (var element in item) { |
| 101 ++actualLength; | 101 ++actualLength; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 if (expectedLength > actualLength) { | 104 if (expectedLength > actualLength) { |
| 105 return 'has too few elements (${actualLength} < ${expectedLength})'; | 105 return 'has too few elements (${actualLength} < ${expectedLength})'; |
| 106 } else if (expectedLength < actualLength) { | 106 } else if (expectedLength < actualLength) { |
| 107 return 'has too many elements (${actualLength} > ${expectedLength})'; | 107 return 'has too many elements (${actualLength} > ${expectedLength})'; |
| 108 } | 108 } |
| 109 List<bool> matched = new List<bool>(actualLength); | 109 List<bool> matched = new List<bool>(actualLength); |
| 110 for (var i = 0; i < actualLength; i++) { |
| 111 matched[i] = false; |
| 112 } |
| 110 var expectedPosition = 0; | 113 var expectedPosition = 0; |
| 111 for (var expectedElement in _expected) { | 114 for (var expectedElement in _expected) { |
| 112 var actualPosition = 0; | 115 var actualPosition = 0; |
| 113 var gotMatch = false; | 116 var gotMatch = false; |
| 114 for (var actualElement in item) { | 117 for (var actualElement in item) { |
| 115 if (!matched[actualPosition]) { | 118 if (!matched[actualPosition]) { |
| 116 if (expectedElement == actualElement) { | 119 if (expectedElement == actualElement) { |
| 117 matched[actualPosition] = gotMatch = true; | 120 matched[actualPosition] = gotMatch = true; |
| 118 break; | 121 break; |
| 119 } | 122 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 148 Description describeMismatch(item, Description mismatchDescription) { | 151 Description describeMismatch(item, Description mismatchDescription) { |
| 149 if (item is !Collection) { | 152 if (item is !Collection) { |
| 150 return mismatchDescription. | 153 return mismatchDescription. |
| 151 addDescriptionOf(item). | 154 addDescriptionOf(item). |
| 152 add(' not a collection'); | 155 add(' not a collection'); |
| 153 } else { | 156 } else { |
| 154 return super.describeMismatch(item, mismatchDescription); | 157 return super.describeMismatch(item, mismatchDescription); |
| 155 } | 158 } |
| 156 } | 159 } |
| 157 } | 160 } |
| OLD | NEW |