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..baf0ee05579682ef7d2655f71ea45f2fc8d77ca2 100644 |
--- a/pkg/matcher/lib/src/core_matchers.dart |
+++ b/pkg/matcher/lib/src/core_matchers.dart |
@@ -26,6 +26,22 @@ class _Empty extends Matcher { |
Description describe(Description description) => description.add('empty'); |
} |
+/// Returns a matcher that matches non-empty strings, maps or iterables |
+// (including collections). |
Lasse Reichstein Nielsen
2014/11/27 15:22:46
Second line isn't part of dartdoc-comment.
Docume
blackhc
2014/11/28 16:12:29
Done.
|
+const Matcher isNotEmpty = const _NotEmpty(); |
+ |
+class _NotEmpty extends Matcher { |
+ const _NotEmpty(); |
+ bool matches(item, Map matchState) { |
+ if (item is Map || item is Iterable || item is String) { |
dskloet
2014/11/27 15:27:53
return (item is Map || item is Iterable || item is
blackhc
2014/11/28 16:12:29
Done.
|
+ return item.isNotEmpty; |
+ } else { |
+ return false; |
+ } |
+ } |
+ Description describe(Description description) => description.add('non-empty'); |
+} |
+ |
/// A matcher that matches any null value. |
const Matcher isNull = const _IsNull(); |