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 import "package:expect/expect.dart"; | |
6 | |
7 class ListIteratorsTest { | 5 class ListIteratorsTest { |
8 static void checkListIterator(List a) { | 6 static void checkListIterator(List a) { |
9 Iterator it = a.iterator; | 7 Iterator it = a.iterator; |
10 Expect.isNull(it.current); | 8 Expect.isNull(it.current); |
11 for (int i = 0; i < a.length; i++) { | 9 for (int i = 0; i < a.length; i++) { |
12 Expect.isTrue(it.moveNext()); | 10 Expect.isTrue(it.moveNext()); |
13 var elem = it.current; | 11 var elem = it.current; |
14 Expect.equals(a[i], elem); | 12 Expect.equals(a[i], elem); |
15 } | 13 } |
16 Expect.isFalse(it.moveNext()); | 14 Expect.isFalse(it.moveNext()); |
(...skipping 24 matching lines...) Expand all Loading... |
41 Expect.equals(3, it.current); | 39 Expect.equals(3, it.current); |
42 Expect.throws(it.moveNext, (e) => e is ConcurrentModificationError); | 40 Expect.throws(it.moveNext, (e) => e is ConcurrentModificationError); |
43 // No progress when throwing. | 41 // No progress when throwing. |
44 Expect.equals(3, it.current); | 42 Expect.equals(3, it.current); |
45 } | 43 } |
46 } | 44 } |
47 | 45 |
48 main() { | 46 main() { |
49 ListIteratorsTest.testMain(); | 47 ListIteratorsTest.testMain(); |
50 } | 48 } |
OLD | NEW |