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

Side by Side Diff: tests/corelib/queue_iterator_test.dart

Issue 11230011: Make hasNext a getter instead of a method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove unused variable. Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/corelib/list_iterators_test.dart ('k') | tests/corelib/reg_exp5_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class QueueIteratorTest { 5 class QueueIteratorTest {
6 static testMain() { 6 static testMain() {
7 testSmallQueue(); 7 testSmallQueue();
8 testLargeQueue(); 8 testLargeQueue();
9 testEmptyQueue(); 9 testEmptyQueue();
10 } 10 }
11 11
12 static void testThrows(Iterator<int> it) { 12 static void testThrows(Iterator<int> it) {
13 Expect.equals(false, it.hasNext()); 13 Expect.equals(false, it.hasNext);
14 var exception = null; 14 var exception = null;
15 try { 15 try {
16 it.next(); 16 it.next();
17 } on NoMoreElementsException catch (e) { 17 } on NoMoreElementsException catch (e) {
18 exception = e; 18 exception = e;
19 } 19 }
20 Expect.equals(true, exception != null); 20 Expect.equals(true, exception != null);
21 } 21 }
22 22
23 static int sum(int expected, Iterator<int> it) { 23 static int sum(int expected, Iterator<int> it) {
24 int count = 0; 24 int count = 0;
25 while (it.hasNext()) { 25 while (it.hasNext) {
26 count += it.next(); 26 count += it.next();
27 } 27 }
28 Expect.equals(expected, count); 28 Expect.equals(expected, count);
29 } 29 }
30 30
31 static void testSmallQueue() { 31 static void testSmallQueue() {
32 Queue<int> queue = new Queue<int>(); 32 Queue<int> queue = new Queue<int>();
33 queue.addLast(1); 33 queue.addLast(1);
34 queue.addLast(2); 34 queue.addLast(2);
35 queue.addLast(3); 35 queue.addLast(3);
36 36
37 Iterator<int> it = queue.iterator(); 37 Iterator<int> it = queue.iterator();
38 Expect.equals(true, it.hasNext()); 38 Expect.equals(true, it.hasNext);
39 sum(6, it); 39 sum(6, it);
40 testThrows(it); 40 testThrows(it);
41 } 41 }
42 42
43 static void testLargeQueue() { 43 static void testLargeQueue() {
44 Queue<int> queue = new Queue<int>(); 44 Queue<int> queue = new Queue<int>();
45 int count = 0; 45 int count = 0;
46 for (int i = 0; i < 100; i++) { 46 for (int i = 0; i < 100; i++) {
47 count += i; 47 count += i;
48 queue.addLast(i); 48 queue.addLast(i);
49 } 49 }
50 Iterator<int> it = queue.iterator(); 50 Iterator<int> it = queue.iterator();
51 Expect.equals(true, it.hasNext()); 51 Expect.equals(true, it.hasNext);
52 sum(count, it); 52 sum(count, it);
53 testThrows(it); 53 testThrows(it);
54 } 54 }
55 55
56 static void testEmptyQueue() { 56 static void testEmptyQueue() {
57 Queue<int> queue = new Queue<int>(); 57 Queue<int> queue = new Queue<int>();
58 Iterator<int> it = queue.iterator(); 58 Iterator<int> it = queue.iterator();
59 Expect.equals(false, it.hasNext()); 59 Expect.equals(false, it.hasNext);
60 sum(0, it); 60 sum(0, it);
61 testThrows(it); 61 testThrows(it);
62 } 62 }
63 } 63 }
64 64
65 main() { 65 main() {
66 QueueIteratorTest.testMain(); 66 QueueIteratorTest.testMain();
67 } 67 }
OLDNEW
« no previous file with comments | « tests/corelib/list_iterators_test.dart ('k') | tests/corelib/reg_exp5_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698