Index: pkg/matcher/lib/src/core_matchers.dart |
diff --git a/pkg/matcher/lib/src/core_matchers.dart b/pkg/matcher/lib/src/core_matchers.dart |
index c3c996d908f27b76033061e179bd73530abe8e45..5e477f48a56d8010b607a1f49825aedcf148eda6 100644 |
--- a/pkg/matcher/lib/src/core_matchers.dart |
+++ b/pkg/matcher/lib/src/core_matchers.dart |
@@ -9,23 +9,30 @@ import 'interfaces.dart'; |
import 'util.dart'; |
/// Returns a matcher that matches empty strings, maps or iterables |
-/// (including collections). |
+/// (including collections) using the isEmpty property. |
const Matcher isEmpty = const _Empty(); |
class _Empty extends Matcher { |
const _Empty(); |
bool matches(item, Map matchState) { |
- if (item is Map || item is Iterable) { |
- return item.isEmpty; |
- } else if (item is String) { |
- return item.length == 0; |
- } else { |
- return false; |
- } |
+ return (item is Map || item is Iterable || item is String) && item.isEmpty; |
} |
Description describe(Description description) => description.add('empty'); |
} |
+/// Returns a matcher that matches non-empty strings, maps or iterables |
+/// (including collections) using the isNotEmpty property. |
+const Matcher isNotEmpty = const _NotEmpty(); |
+ |
+class _NotEmpty extends Matcher { |
+ const _NotEmpty(); |
+ bool matches(item, Map matchState) { |
nweiz
2014/12/01 22:18:07
Nit: empty lines between members.
The existing co
blackhc
2014/12/03 10:07:17
Done.
|
+ return (item is Map || item is Iterable || item is String) && |
+ item.isNotEmpty; |
+ } |
+ Description describe(Description description) => description.add('non-empty'); |
+} |
+ |
/// A matcher that matches any null value. |
const Matcher isNull = const _IsNull(); |