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

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

Issue 11644072: Add ordered set. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: 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
« sdk/lib/core/set.dart ('K') | « sdk/lib/core/set.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 main() {
6 var it, i;
7 var entries = [1, 2, 3, 4, 499, 42];
8 var set = new OrderedSet();
9 set.addAll(entries);
10
11 Expect.listEquals([1, 2, 3, 4, 499, 42], set.toList());
12 it = set.iterator;
13 i = 0;
14 while (it.moveNext()) {
15 Expect.equals(entries[i++], it.current);
16 }
17 // Add the entries in reverse order and make sure that this doesn't change
18 // the internal order.
19 for (int j = entries.length - 1; j >= 0; j--) {
20 set.add(entries[j]);
21 }
22 Expect.listEquals([1, 2, 3, 4, 499, 42], set.toList());
23 it = set.iterator;
24 i = 0;
25 while (it.moveNext()) {
26 Expect.equals(entries[i++], it.current);
27 }
28
29 set = new OrderedSet.from(entries);
30 Expect.listEquals([1, 2, 3, 4, 499, 42], set.toList());
31 it = set.iterator;
32 i = 0;
33 while (it.moveNext()) {
34 Expect.equals(entries[i++], it.current);
35 }
36 // Add the entries in reverse order and make sure that this doesn't change
37 // the internal order.
38 for (int j = entries.length - 1; j >= 0; j--) {
39 set.add(entries[j]);
40 }
41 Expect.listEquals([1, 2, 3, 4, 499, 42], set.toList());
42 it = set.iterator;
43 i = 0;
44 while (it.moveNext()) {
45 Expect.equals(entries[i++], it.current);
46 }
47 }
OLDNEW
« sdk/lib/core/set.dart ('K') | « sdk/lib/core/set.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698