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

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

Issue 14173003: Remove Collection, Collections and clean up List/Set/Queue implementations of retain/remove. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « pkg/unittest/lib/src/core_matchers.dart ('k') | 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/iterable_matchers.dart
diff --git a/pkg/unittest/lib/src/collection_matchers.dart b/pkg/unittest/lib/src/iterable_matchers.dart
similarity index 86%
rename from pkg/unittest/lib/src/collection_matchers.dart
rename to pkg/unittest/lib/src/iterable_matchers.dart
index 7f3a64c90e9c272d71dfcbae94f4b89b64830d77..e5b0e9acd3cf1b5ec804091099f6f984831316d7 100644
--- a/pkg/unittest/lib/src/collection_matchers.dart
+++ b/pkg/unittest/lib/src/iterable_matchers.dart
@@ -5,12 +5,12 @@
part of matcher;
/**
- * Returns a matcher which matches [Collection]s in which all elements
+ * Returns a matcher which matches [Iterable]s in which all elements
* match the given [matcher].
*/
Matcher everyElement(matcher) => new _EveryElement(wrapMatcher(matcher));
-class _EveryElement extends _CollectionMatcher {
+class _EveryElement extends _IterableMatcher {
Matcher _matcher;
_EveryElement(Matcher this._matcher);
@@ -51,12 +51,12 @@ class _EveryElement extends _CollectionMatcher {
}
/**
- * Returns a matcher which matches [Collection]s in which at least one
+ * Returns a matcher which matches [Iterable]s in which at least one
* element matches the given [matcher].
*/
Matcher someElement(matcher) => new _SomeElement(wrapMatcher(matcher));
-class _SomeElement extends _CollectionMatcher {
+class _SomeElement extends _IterableMatcher {
Matcher _matcher;
_SomeElement(this._matcher);
@@ -120,23 +120,8 @@ class _UnorderedEquals extends BaseMatcher {
return 'not iterable';
}
// Check the lengths are the same.
- var expectedLength = 0;
- if (_expected is Collection) {
- Collection cast = _expected; // "_expected as Collection"
- expectedLength = cast.length;
- } else {
- for (var element in _expected) {
- ++expectedLength;
- }
- }
- var actualLength = 0;
- if (item is Collection) {
- actualLength = item.length;
- } else {
- for (var element in item) {
- ++actualLength;
- }
- }
+ var expectedLength = _expected.length;
+ var actualLength = item.length;
if (expectedLength > actualLength) {
return 'has too few elements (${actualLength} < ${expectedLength})';
} else if (expectedLength < actualLength) {
@@ -182,11 +167,11 @@ class _UnorderedEquals extends BaseMatcher {
}
/**
- * Collection matchers match against [Collection]s. We add this intermediate
+ * Iterable matchers match against [Iterable]s. We add this intermediate
* class to give better mismatch error messages than the base Matcher class.
*/
-abstract class _CollectionMatcher extends BaseMatcher {
- const _CollectionMatcher();
+abstract class _IterableMatcher extends BaseMatcher {
+ const _IterableMatcher();
Description describeMismatch(item, Description mismatchDescription,
MatchState matchState, bool verbose) {
if (item is! Iterable) {
« no previous file with comments | « pkg/unittest/lib/src/core_matchers.dart ('k') | pkg/unittest/test/matchers_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698