| 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 /** | 6 /** |
| 7 * Returns a matcher that matches empty strings, maps or collections. | 7 * Returns a matcher that matches empty strings, maps or collections. |
| 8 */ | 8 */ |
| 9 const Matcher isEmpty = const _Empty(); | 9 const Matcher isEmpty = const _Empty(); |
| 10 | 10 |
| 11 class _Empty extends BaseMatcher { | 11 class _Empty extends BaseMatcher { |
| 12 const _Empty(); | 12 const _Empty(); |
| 13 bool matches(item, MatchState matchState) { | 13 bool matches(item, MatchState matchState) { |
| 14 if (item is Map || item is Collection) { | 14 if (item is Map || item is Collection) { |
| 15 return item.isEmpty(); | 15 return item.isEmpty; |
| 16 } else if (item is String) { | 16 } else if (item is String) { |
| 17 return item.length == 0; | 17 return item.length == 0; |
| 18 } else { | 18 } else { |
| 19 return false; | 19 return false; |
| 20 } | 20 } |
| 21 } | 21 } |
| 22 Description describe(Description description) => | 22 Description describe(Description description) => |
| 23 description.add('empty'); | 23 description.add('empty'); |
| 24 } | 24 } |
| 25 | 25 |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 final _matcher; | 618 final _matcher; |
| 619 final String _description; | 619 final String _description; |
| 620 | 620 |
| 621 const _Predicate(this._matcher, this._description); | 621 const _Predicate(this._matcher, this._description); |
| 622 | 622 |
| 623 bool matches(item, MatchState matchState) => _matcher(item); | 623 bool matches(item, MatchState matchState) => _matcher(item); |
| 624 | 624 |
| 625 Description describe(Description description) => | 625 Description describe(Description description) => |
| 626 description.add(_description); | 626 description.add(_description); |
| 627 } | 627 } |
| OLD | NEW |