| 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 that matches empty strings, maps or collections. | 8 * Returns a matcher that matches empty strings, maps or collections. |
| 9 */ | 9 */ |
| 10 const Matcher isEmpty = const _Empty(); | 10 const Matcher isEmpty = const _Empty(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 final _expected; | 91 final _expected; |
| 92 final int _limit; | 92 final int _limit; |
| 93 var count; | 93 var count; |
| 94 | 94 |
| 95 _DeepMatcher(this._expected, [limit = 1000]) : this._limit = limit; | 95 _DeepMatcher(this._expected, [limit = 1000]) : this._limit = limit; |
| 96 | 96 |
| 97 String _compareIterables(expected, actual, matcher, depth) { | 97 String _compareIterables(expected, actual, matcher, depth) { |
| 98 if (actual is !Iterable) { | 98 if (actual is !Iterable) { |
| 99 return 'is not Iterable'; | 99 return 'is not Iterable'; |
| 100 } | 100 } |
| 101 var expectedIterator = expected.iterator(); | 101 var expectedIterator = expected.iterator; |
| 102 var actualIterator = actual.iterator(); | 102 var actualIterator = actual.iterator; |
| 103 var position = 0; | 103 var position = 0; |
| 104 String reason = null; | 104 String reason = null; |
| 105 while (reason == null) { | 105 while (reason == null) { |
| 106 if (expectedIterator.hasNext) { | 106 if (expectedIterator.moveNext()) { |
| 107 if (actualIterator.hasNext) { | 107 if (actualIterator.moveNext()) { |
| 108 Description r = matcher(expectedIterator.next(), | 108 Description r = matcher(expectedIterator.current, |
| 109 actualIterator.next(), | 109 actualIterator.current, |
| 110 'mismatch at position ${position}', | 110 'mismatch at position ${position}', |
| 111 depth); | 111 depth); |
| 112 if (r != null) reason = r.toString(); | 112 if (r != null) reason = r.toString(); |
| 113 ++position; | 113 ++position; |
| 114 } else { | 114 } else { |
| 115 reason = 'shorter than expected'; | 115 reason = 'shorter than expected'; |
| 116 } | 116 } |
| 117 } else if (actualIterator.hasNext) { | 117 } else if (actualIterator.moveNext()) { |
| 118 reason = 'longer than expected'; | 118 reason = 'longer than expected'; |
| 119 } else { | 119 } else { |
| 120 return null; | 120 return null; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 return reason; | 123 return reason; |
| 124 } | 124 } |
| 125 | 125 |
| 126 Description _recursiveMatch(expected, actual, String location, int depth) { | 126 Description _recursiveMatch(expected, actual, String location, int depth) { |
| 127 Description reason = null; | 127 Description reason = null; |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); | 689 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); |
| 690 | 690 |
| 691 Description describeMismatch(item, Description mismatchDescription, | 691 Description describeMismatch(item, Description mismatchDescription, |
| 692 MatchState matchState, bool verbose) { | 692 MatchState matchState, bool verbose) { |
| 693 mismatchDescription.add(_featureName).add(' '); | 693 mismatchDescription.add(_featureName).add(' '); |
| 694 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, | 694 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, |
| 695 matchState.state['innerState'], verbose); | 695 matchState.state['innerState'], verbose); |
| 696 return mismatchDescription; | 696 return mismatchDescription; |
| 697 } | 697 } |
| 698 } | 698 } |
| OLD | NEW |