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

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

Issue 11312122: Change List constructors. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Reupload. Adapt code for List.fixedLength. Created 8 years 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_index_of_test.dart ('k') | tests/corelib/list_removeat_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 ListIteratorsTest { 5 class ListIteratorsTest {
6 static void checkListIterator(List a) { 6 static void checkListIterator(List a) {
7 Iterator it = a.iterator; 7 Iterator it = a.iterator;
8 for (int i = 0; i < a.length; i++) { 8 for (int i = 0; i < a.length; i++) {
9 Expect.isTrue(it.moveNext()); 9 Expect.isTrue(it.moveNext());
10 var elem = it.current; 10 var elem = it.current;
11 Expect.equals(a[i], elem); 11 Expect.equals(a[i], elem);
12 } 12 }
13 Expect.isFalse(it.moveNext()); 13 Expect.isFalse(it.moveNext());
14 Expect.isNull(it.current); 14 Expect.isNull(it.current);
15 } 15 }
16 16
17 static testMain() { 17 static testMain() {
18 checkListIterator([]); 18 checkListIterator([]);
19 checkListIterator([1, 2]); 19 checkListIterator([1, 2]);
20 checkListIterator(new List(0)); 20 checkListIterator(new List.fixedLength(0));
21 checkListIterator(new List(10)); 21 checkListIterator(new List.fixedLength(10));
22 checkListIterator(new List()); 22 checkListIterator(new List());
23 List g = new List(); 23 List g = new List();
24 g.addAll([1, 2, 3]); 24 g.addAll([1, 2, 3]);
25 checkListIterator(g); 25 checkListIterator(g);
26 26
27 // This is mostly undefined behavior. 27 // This is mostly undefined behavior.
28 Iterator it = g.iterator; 28 Iterator it = g.iterator;
29 Expect.isTrue(it.moveNext()); 29 Expect.isTrue(it.moveNext());
30 g.removeLast(); 30 g.removeLast();
31 Expect.equals(1, it.current); 31 Expect.equals(1, it.current);
(...skipping 15 matching lines...) Expand all
47 // Iterator must realize that g has no more elements. 47 // Iterator must realize that g has no more elements.
48 g.removeLast(); 48 g.removeLast();
49 } 49 }
50 Expect.equals(10, sum); 50 Expect.equals(10, sum);
51 } 51 }
52 } 52 }
53 53
54 main() { 54 main() {
55 ListIteratorsTest.testMain(); 55 ListIteratorsTest.testMain();
56 } 56 }
OLDNEW
« no previous file with comments | « tests/corelib/list_index_of_test.dart ('k') | tests/corelib/list_removeat_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698