| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Returns a matches that matches if the value is the same instance | 68 * Returns a matches that matches if the value is the same instance |
| 69 * as [object] (`===`). | 69 * as [object] (`===`). |
| 70 */ | 70 */ |
| 71 Matcher same(expected) => new _IsSameAs(expected); | 71 Matcher same(expected) => new _IsSameAs(expected); |
| 72 | 72 |
| 73 class _IsSameAs extends BaseMatcher { | 73 class _IsSameAs extends BaseMatcher { |
| 74 final _expected; | 74 final _expected; |
| 75 const _IsSameAs(this._expected); | 75 const _IsSameAs(this._expected); |
| 76 bool matches(item, MatchState matchState) => item === _expected; | 76 bool matches(item, MatchState matchState) => identical(item, _expected); |
| 77 // If all types were hashable we could show a hash here. | 77 // If all types were hashable we could show a hash here. |
| 78 Description describe(Description description) => | 78 Description describe(Description description) => |
| 79 description.add('same instance as ').addDescriptionOf(_expected); | 79 description.add('same instance as ').addDescriptionOf(_expected); |
| 80 } | 80 } |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * Returns a matcher that does a deep recursive match. This only works | 83 * Returns a matcher that does a deep recursive match. This only works |
| 84 * with scalars, Maps and Iterables. To handle cyclic structures a | 84 * with scalars, Maps and Iterables. To handle cyclic structures a |
| 85 * recursion depth [limit] can be provided. The default limit is 100. | 85 * recursion depth [limit] can be provided. The default limit is 100. |
| 86 */ | 86 */ |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); | 711 description.add(_featureDescription).add(' ').addDescriptionOf(_matcher); |
| 712 | 712 |
| 713 Description describeMismatch(item, Description mismatchDescription, | 713 Description describeMismatch(item, Description mismatchDescription, |
| 714 MatchState matchState, bool verbose) { | 714 MatchState matchState, bool verbose) { |
| 715 mismatchDescription.add(_featureName).add(' '); | 715 mismatchDescription.add(_featureName).add(' '); |
| 716 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, | 716 _matcher.describeMismatch(matchState.state['feature'], mismatchDescription, |
| 717 matchState.state['innerState'], verbose); | 717 matchState.state['innerState'], verbose); |
| 718 return mismatchDescription; | 718 return mismatchDescription; |
| 719 } | 719 } |
| 720 } | 720 } |
| OLD | NEW |