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

Unified Diff: tests/corelib/iterable_skip_test.dart

Issue 12295009: Recommit changing List.skip/take/revert returns Iterable and remove mappedBy. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make Future.wait simpler. 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
Index: tests/corelib/iterable_skip_test.dart
diff --git a/tests/corelib/iterable_skip_test.dart b/tests/corelib/iterable_skip_test.dart
index fff6db71999bed5a428a9b3414480dc9b7c18ec2..b02e72a10704ae63ce865bbc5068d581c9c4fd01 100644
--- a/tests/corelib/iterable_skip_test.dart
+++ b/tests/corelib/iterable_skip_test.dart
@@ -13,7 +13,7 @@ main() {
Set set2 = new Set();
Iterable<int> skip0 = list1.skip(0);
- Expect.isTrue(skip0 is List);
+ Expect.isTrue(skip0 is! List);
Iterator<int> it = skip0.iterator;
Expect.isNull(it.current);
Expect.isTrue(it.moveNext());
@@ -26,8 +26,8 @@ main() {
Expect.isNull(it.current);
Iterable<int> skip1 = list1.skip(1);
- Expect.isTrue(skip1 is List);
- Expect.isTrue(skip1.skip(2).skip(1) is List);
+ Expect.isTrue(skip1 is! List);
+ Expect.isTrue(skip1.skip(2).skip(1) is! List);
it = skip1.iterator;
Expect.isNull(it.current);
Expect.isTrue(it.moveNext());
@@ -38,8 +38,8 @@ main() {
Expect.isNull(it.current);
Iterable<int> skip2 = list1.skip(2);
- Expect.isTrue(skip2 is List);
- Expect.isTrue(skip2.skip(2).skip(1) is List);
+ Expect.isTrue(skip2 is! List);
+ Expect.isTrue(skip2.skip(2).skip(1) is! List);
it = skip2.iterator;
Expect.isNull(it.current);
Expect.isTrue(it.moveNext());
@@ -48,16 +48,16 @@ main() {
Expect.isNull(it.current);
Iterable<int> skip3 = list1.skip(3);
- Expect.isTrue(skip3 is List);
- Expect.isTrue(skip3.skip(2).skip(1) is List);
+ Expect.isTrue(skip3 is! List);
+ Expect.isTrue(skip3.skip(2).skip(1) is! List);
it = skip3.iterator;
Expect.isNull(it.current);
Expect.isFalse(it.moveNext());
Expect.isNull(it.current);
Iterable<int> skip4 = list1.skip(4);
- Expect.isTrue(skip4 is List);
- Expect.isTrue(skip4.skip(2).skip(1) is List);
+ Expect.isTrue(skip4 is! List);
+ Expect.isTrue(skip4.skip(2).skip(1) is! List);
it = skip4.iterator;
Expect.isNull(it.current);
Expect.isFalse(it.moveNext());
@@ -102,8 +102,8 @@ main() {
Expect.isNull(it.current);
skip0 = list2.skip(0);
- Expect.isTrue(skip0 is List);
- Expect.isTrue(skip0.skip(2).skip(1) is List);
+ Expect.isTrue(skip0 is! List);
+ Expect.isTrue(skip0.skip(2).skip(1) is! List);
it = skip0.iterator;
Expect.isNull(it.current);
Expect.isTrue(it.moveNext());
@@ -114,8 +114,8 @@ main() {
Expect.isNull(it.current);
skip1 = list2.skip(1);
- Expect.isTrue(skip1 is List);
- Expect.isTrue(skip1.skip(2).skip(1) is List);
+ Expect.isTrue(skip1 is! List);
+ Expect.isTrue(skip1.skip(2).skip(1) is! List);
it = skip1.iterator;
Expect.isNull(it.current);
Expect.isTrue(it.moveNext());
@@ -124,32 +124,32 @@ main() {
Expect.isNull(it.current);
skip2 = list2.skip(2);
- Expect.isTrue(skip2 is List);
- Expect.isTrue(skip2.skip(2).skip(1) is List);
+ Expect.isTrue(skip2 is! List);
+ Expect.isTrue(skip2.skip(2).skip(1) is! List);
it = skip2.iterator;
Expect.isNull(it.current);
Expect.isFalse(it.moveNext());
Expect.isNull(it.current);
skip3 = list2.skip(3);
- Expect.isTrue(skip3 is List);
- Expect.isTrue(skip3.skip(2).skip(1) is List);
+ Expect.isTrue(skip3 is! List);
+ Expect.isTrue(skip3.skip(2).skip(1) is! List);
it = skip3.iterator;
Expect.isNull(it.current);
Expect.isFalse(it.moveNext());
Expect.isNull(it.current);
Iterable<String> skip02 = list3.skip(0);
- Expect.isTrue(skip02 is List);
- Expect.isTrue(skip02.skip(2).skip(1) is List);
+ Expect.isTrue(skip02 is! List);
+ Expect.isTrue(skip02.skip(2).skip(1) is! List);
Iterator<String> it2 = skip02.iterator;
Expect.isNull(it2.current);
Expect.isFalse(it2.moveNext());
Expect.isNull(it2.current);
Iterable<String> skip12 = list3.skip(1);
- Expect.isTrue(skip12 is List);
- Expect.isTrue(skip12.skip(2).skip(1) is List);
+ Expect.isTrue(skip12 is! List);
+ Expect.isTrue(skip12.skip(2).skip(1) is! List);
it2 = skip12.iterator;
Expect.isNull(it2.current);
Expect.isFalse(it2.moveNext());
@@ -224,4 +224,33 @@ main() {
Expect.isNull(it.current);
Expect.isFalse(it.moveNext());
Expect.isNull(it.current);
+
+ testSkipTake(Iterable input, int skip, int take) {
+ List expected = [];
+ Iterator iter = input.iterator;
+ for (int i = 0; i < skip; i++) iter.moveNext();
+ for (int i = 0; i < take; i++) {
+ if (!iter.moveNext()) break;
+ expected.add(iter.current);
+ }
+ Expect.listEquals(expected, input.skip(skip).take(take).toList());
+ }
+
+ List longList = [1, 4, 5, 3, 8, 11, 12, 6, 9, 10, 13, 7, 2, 14, 15];
+ Set bigSet = longList.toSet();
+
+ for (Iterable collection in [longList, longList.reversed, bigSet]) {
+ testSkipTake(collection, 0, 0);
+ testSkipTake(collection, 0, 5);
+ testSkipTake(collection, 0, 15);
+ testSkipTake(collection, 0, 25);
+ testSkipTake(collection, 5, 0);
+ testSkipTake(collection, 5, 5);
+ testSkipTake(collection, 5, 10);
+ testSkipTake(collection, 5, 20);
+ testSkipTake(collection, 15, 0);
+ testSkipTake(collection, 15, 5);
+ testSkipTake(collection, 20, 0);
+ testSkipTake(collection, 20, 5);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698