Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: pkg/unittest/lib/src/core_matchers.dart

Issue 12224053: Updated contains and isEmpty matches to use iterables. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/unittest/test/matchers_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/src/core_matchers.dart
diff --git a/pkg/unittest/lib/src/core_matchers.dart b/pkg/unittest/lib/src/core_matchers.dart
index 449990b0b1518710fb892a4e00bfe0dfc361cfb8..ce24e047afe88588fad9d3e04dbc834950459ab6 100644
--- a/pkg/unittest/lib/src/core_matchers.dart
+++ b/pkg/unittest/lib/src/core_matchers.dart
@@ -12,7 +12,7 @@ const Matcher isEmpty = const _Empty();
class _Empty extends BaseMatcher {
const _Empty();
bool matches(item, MatchState matchState) {
- if (item is Map || item is Collection) {
+ if (item is Map || item is Iterable) {
return item.isEmpty;
} else if (item is String) {
return item.length == 0;
@@ -587,11 +587,11 @@ class _Contains extends BaseMatcher {
bool matches(item, MatchState matchState) {
if (item is String) {
return item.indexOf(_expected) >= 0;
- } else if (item is Collection) {
+ } else if (item is Iterable) {
if (_expected is Matcher) {
return item.any((e) => _expected.matches(e, matchState));
} else {
- return item.any((e) => e == _expected);
+ return item.contains(_expected);
butlermatt 2013/02/07 15:30:28 I changed this to contains(), to allow Iterables t
}
} else if (item is Map) {
return item.containsKey(_expected);
« no previous file with comments | « no previous file | pkg/unittest/test/matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698