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

Unified Diff: tests/corelib/iterable_skip_test.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « tests/corelib/iterable_single_test.dart ('k') | tests/corelib/iterable_skip_while_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/iterable_skip_test.dart
diff --git a/tests/corelib/iterable_skip_test.dart b/tests/corelib/iterable_skip_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..63e6ef421bdbe7bd10139d135d863d74449c27f2
--- /dev/null
+++ b/tests/corelib/iterable_skip_test.dart
@@ -0,0 +1,206 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+main() {
+ List<int> list1 = <int>[1, 2, 3];
+ List<int> list2 = const <int>[4, 5];
+ List<String> list3 = <String>[];
+ Set<int> set1 = new Set<int>();
+ set1..add(11)
+ ..add(12)
+ ..add(13);
+ Set set2 = new Set();
+
+ Iterable<int> skip0 = list1.skip(0);
+ Iterator<int> it = skip0.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skip1 = list1.skip(1);
+ it = skip1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skip2 = list1.skip(2);
+ it = skip2.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skip3 = list1.skip(3);
+ it = skip3.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<int> skip4 = list1.skip(4);
+ it = skip4.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip0 = list1.skip(0);
+ skip1 = skip0.skip(1);
+ skip2 = skip1.skip(1);
+ skip3 = skip2.skip(1);
+ skip4 = skip3.skip(1);
+ it = skip0.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(1, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = skip1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(2, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = skip2.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(3, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = skip3.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+ it = skip4.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip0 = list2.skip(0);
+ it = skip0.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(4, it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(5, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip1 = list2.skip(1);
+ it = skip1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.equals(5, it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip2 = list2.skip(2);
+ it = skip2.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip3 = list2.skip(3);
+ it = skip3.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ Iterable<String> skip02 = list3.skip(0);
+ Iterator<String> it2 = skip02.iterator;
+ Expect.isNull(it2.current);
+ Expect.isFalse(it2.moveNext());
+ Expect.isNull(it2.current);
+
+ Iterable<String> skip12 = list3.skip(1);
+ it2 = skip12.iterator;
+ Expect.isNull(it2.current);
+ Expect.isFalse(it2.moveNext());
+ Expect.isNull(it2.current);
+
+ skip0 = set1.skip(0);
+ List<int> copied = skip0.toList();
+ Expect.equals(3, copied.length);
+ Expect.isTrue(set1.contains(copied[0]));
+ Expect.isTrue(set1.contains(copied[1]));
+ Expect.isTrue(set1.contains(copied[2]));
+ Expect.isTrue(copied[0] != copied[1]);
+ Expect.isTrue(copied[0] != copied[2]);
+ Expect.isTrue(copied[1] != copied[2]);
+ it = skip0.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip1 = set1.skip(1);
+ copied = skip1.toList();
+ Expect.equals(2, copied.length);
+ Expect.isTrue(set1.contains(copied[0]));
+ Expect.isTrue(set1.contains(copied[1]));
+ Expect.isTrue(copied[0] != copied[1]);
+ it = skip1.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip2 = set1.skip(2);
+ copied = skip2.toList();
+ Expect.equals(1, copied.length);
+ Expect.isTrue(set1.contains(copied[0]));
+ it = skip2.iterator;
+ Expect.isNull(it.current);
+ Expect.isTrue(it.moveNext());
+ Expect.isNotNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip3 = set1.skip(3);
+ it = skip3.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip4 = set1.skip(4);
+ it = skip4.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip0 = set2.skip(0);
+ it = skip0.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+
+ skip1 = set2.skip(1);
+ it = skip1.iterator;
+ Expect.isNull(it.current);
+ Expect.isFalse(it.moveNext());
+ Expect.isNull(it.current);
+}
« no previous file with comments | « tests/corelib/iterable_single_test.dart ('k') | tests/corelib/iterable_skip_while_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698