OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library hasNextIterator.test; |
| 6 import 'dart:collection'; |
| 7 |
5 main() { | 8 main() { |
6 var it = new HasNextIterator([].iterator); | 9 var it = new HasNextIterator([].iterator); |
7 Expect.isFalse(it.hasNext); | 10 Expect.isFalse(it.hasNext); |
8 Expect.isFalse(it.hasNext); | 11 Expect.isFalse(it.hasNext); |
9 Expect.throws(() => it.next(), (e) => e is StateError); | 12 Expect.throws(() => it.next(), (e) => e is StateError); |
10 Expect.isFalse(it.hasNext); | 13 Expect.isFalse(it.hasNext); |
11 | 14 |
12 it = new HasNextIterator([1].iterator); | 15 it = new HasNextIterator([1].iterator); |
13 Expect.isTrue(it.hasNext); | 16 Expect.isTrue(it.hasNext); |
14 Expect.isTrue(it.hasNext); | 17 Expect.isTrue(it.hasNext); |
15 Expect.equals(1, it.next()); | 18 Expect.equals(1, it.next()); |
16 Expect.isFalse(it.hasNext); | 19 Expect.isFalse(it.hasNext); |
17 Expect.isFalse(it.hasNext); | 20 Expect.isFalse(it.hasNext); |
18 Expect.throws(() => it.next(), (e) => e is StateError); | 21 Expect.throws(() => it.next(), (e) => e is StateError); |
19 Expect.isFalse(it.hasNext); | 22 Expect.isFalse(it.hasNext); |
20 | 23 |
21 it = new HasNextIterator([1, 2].iterator); | 24 it = new HasNextIterator([1, 2].iterator); |
22 Expect.isTrue(it.hasNext); | 25 Expect.isTrue(it.hasNext); |
23 Expect.isTrue(it.hasNext); | 26 Expect.isTrue(it.hasNext); |
24 Expect.equals(1, it.next()); | 27 Expect.equals(1, it.next()); |
25 Expect.isTrue(it.hasNext); | 28 Expect.isTrue(it.hasNext); |
26 Expect.isTrue(it.hasNext); | 29 Expect.isTrue(it.hasNext); |
27 Expect.equals(2, it.next()); | 30 Expect.equals(2, it.next()); |
28 Expect.isFalse(it.hasNext); | 31 Expect.isFalse(it.hasNext); |
29 Expect.isFalse(it.hasNext); | 32 Expect.isFalse(it.hasNext); |
30 Expect.throws(() => it.next(), (e) => e is StateError); | 33 Expect.throws(() => it.next(), (e) => e is StateError); |
31 Expect.isFalse(it.hasNext); | 34 Expect.isFalse(it.hasNext); |
32 } | 35 } |
OLD | NEW |