| OLD | NEW |
| 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 StateError 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 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 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 } |
| OLD | NEW |