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

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

Issue 2987203002: Migrated test block 17 to Dart 2.0. (Closed)
Patch Set: Removed tests that are no longer useful for Dart 2.0 Created 3 years, 4 months 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
« no previous file with comments | « tests/corelib/queue_first_test.dart ('k') | tests/corelib/queue_last_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
(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 library queue.iterator.test;
6
7 import "package:expect/expect.dart";
8 import 'dart:collection' show Queue;
9
10 class QueueIteratorTest {
11 static testMain() {
12 testSmallQueue();
13 testLargeQueue();
14 testEmptyQueue();
15 }
16
17 static int sum(int expected, Iterator<int> it) {
18 int count = 0;
19 while (it.moveNext()) {
20 count += it.current;
21 }
22 Expect.equals(expected, count);
23 }
24
25 static void testSmallQueue() {
26 Queue<int> queue = new Queue<int>();
27 queue.addLast(1);
28 queue.addLast(2);
29 queue.addLast(3);
30
31 Iterator<int> it = queue.iterator;
32 sum(6, it);
33 Expect.isFalse(it.moveNext());
34 Expect.isNull(it.current);
35 }
36
37 static void testLargeQueue() {
38 Queue<int> queue = new Queue<int>();
39 int count = 0;
40 for (int i = 0; i < 100; i++) {
41 count += i;
42 queue.addLast(i);
43 }
44 Iterator<int> it = queue.iterator;
45 sum(count, it);
46 Expect.isFalse(it.moveNext());
47 Expect.isNull(it.current);
48 }
49
50 static void testEmptyQueue() {
51 Queue<int> queue = new Queue<int>();
52 Iterator<int> it = queue.iterator;
53 sum(0, it);
54 Expect.isFalse(it.moveNext());
55 Expect.isNull(it.current);
56 }
57 }
58
59 main() {
60 QueueIteratorTest.testMain();
61 }
OLDNEW
« no previous file with comments | « tests/corelib/queue_first_test.dart ('k') | tests/corelib/queue_last_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698