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

Unified Diff: tests/corelib/set_iterator_test.dart

Issue 11410086: Use iterator, moveNext(), current. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Address comments. Created 8 years, 1 month 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/set_iterator_test.dart
diff --git a/tests/corelib/set_iterator_test.dart b/tests/corelib/set_iterator_test.dart
index 08135e4110f599e27802577135979d3dc46a8237..607de1db0e54bfe6c563c4e9e17fa4c1b8c490e9 100644
--- a/tests/corelib/set_iterator_test.dart
+++ b/tests/corelib/set_iterator_test.dart
@@ -20,20 +20,14 @@ class SetIteratorTest {
}
static void testThrows(Iterator<int> it) {
- Expect.equals(false, it.hasNext);
- var exception = null;
- try {
- it.next();
- } on StateError catch (e) {
- exception = e;
- }
- Expect.equals(true, exception != null);
+ Expect.isFalse(it.moveNext());
+ Expect.throws(() { it.current; }, (e) => e is StateError);
}
static int sum(int expected, Iterator<int> it) {
int count = 0;
- while (it.hasNext) {
- count += it.next();
+ while (it.moveNext()) {
+ count += it.current;
}
Expect.equals(expected, count);
}
@@ -44,8 +38,7 @@ class SetIteratorTest {
set.add(2);
set.add(3);
- Iterator<int> it = set.iterator();
- Expect.equals(true, it.hasNext);
+ Iterator<int> it = set.iterator;
sum(6, it);
testThrows(it);
}
@@ -57,16 +50,14 @@ class SetIteratorTest {
count += i;
set.add(i);
}
- Iterator<int> it = set.iterator();
- Expect.equals(true, it.hasNext);
+ Iterator<int> it = set.iterator;
sum(count, it);
testThrows(it);
}
static void testEmptySet() {
Set<int> set = new Set<int>();
- Iterator<int> it = set.iterator();
- Expect.equals(false, it.hasNext);
+ Iterator<int> it = set.iterator;
sum(0, it);
testThrows(it);
}
@@ -79,8 +70,9 @@ class SetIteratorTest {
for (int i = 0; i < 100; i++) {
set.remove(i);
}
- Iterator<int> it = set.iterator();
- Expect.equals(false, it.hasNext);
+ Iterator<int> it = set.iterator;
+ Expect.isFalse(it.moveNext());
+ it = set.iterator;
sum(0, it);
testThrows(it);
@@ -90,8 +82,7 @@ class SetIteratorTest {
if (i % 2 == 0) set.remove(i);
else count += i;
}
- it = set.iterator();
- Expect.equals(true, it.hasNext);
+ it = set.iterator;
sum(count, it);
testThrows(it);
}

Powered by Google App Engine
This is Rietveld 408576698