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

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

Issue 12787003: Fix bug in queue_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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
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 library queue.test; 5 library queue.test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 abstract class QueueTest { 9 abstract class QueueTest {
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 queue = newQueue(); 110 queue = newQueue();
111 queue.add(0); 111 queue.add(0);
112 for (int i = 0; i < 255; i++) { 112 for (int i = 0; i < 255; i++) {
113 queue.add(i + 1); 113 queue.add(i + 1);
114 Expect.equals(i, queue.removeFirst()); 114 Expect.equals(i, queue.removeFirst());
115 } 115 }
116 Expect.equals(255, queue.removeFirst()); 116 Expect.equals(255, queue.removeFirst());
117 Expect.isTrue(queue.isEmpty); 117 Expect.isTrue(queue.isEmpty);
118 118
119 testAddAll(); 119 testAddAll();
120 testLengthChanges();
120 testLarge(); 121 testLarge();
121 testFromListToList(); 122 testFromListToList();
122 } 123 }
123 124
124 void checkQueue(Queue queue, int expectedSize, int expectedSum) { 125 void checkQueue(Queue queue, int expectedSize, int expectedSum) {
125 Expect.equals(expectedSize, queue.length); 126 Expect.equals(expectedSize, queue.length);
126 int sum = 0; 127 int sum = 0;
127 void sumElements(int value) { 128 void sumElements(int value) {
128 sum += value; 129 sum += value;
129 } 130 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // modifications; 192 // modifications;
192 Queue queue = newQueue(); 193 Queue queue = newQueue();
193 testLength(0, queue); 194 testLength(0, queue);
194 195
195 for (int i = 1; i <= 10; i++) { 196 for (int i = 1; i <= 10; i++) {
196 queue.add(i); 197 queue.add(i);
197 testLength(i, queue); 198 testLength(i, queue);
198 } 199 }
199 200
200 for (int i = 1; i <= 10; i++) { 201 for (int i = 1; i <= 10; i++) {
201 queue.addFirst(i); 202 queue.addFirst(11 - i);
202 testLength(10 + i, queue); 203 testLength(10 + i, queue);
203 } 204 }
204 205
205 for (int i = 1; i <= 10; i++) { 206 for (int i = 1; i <= 10; i++) {
206 queue.addLast(i); 207 queue.addLast(i);
207 testLength(20 + i, queue); 208 testLength(20 + i, queue);
208 } 209 }
209 210
210 queue.addAll([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); 211 queue.addAll([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
211 testLength(40, queue); 212 testLength(40, queue);
(...skipping 10 matching lines...) Expand all
222 223
223 queue.remove(10); 224 queue.remove(10);
224 testLength(29, queue); 225 testLength(29, queue);
225 226
226 queue.removeAll([4, 6]); 227 queue.removeAll([4, 6]);
227 testLength(23, queue); 228 testLength(23, queue);
228 229
229 queue.retainAll([1, 3, 5, 7, 9, 10]); // Remove 2 and 8. 230 queue.retainAll([1, 3, 5, 7, 9, 10]); // Remove 2 and 8.
230 testLength(17, queue); 231 testLength(17, queue);
231 232
232 queue.removeMatching((x) = x == 7); 233 queue.removeMatching((x) => x == 7);
233 testLength(14, queue); 234 testLength(14, queue);
234 235
235 queue.retainMatching((x) = x != 3); 236 queue.retainMatching((x) => x != 3);
236 testLength(11, queue); 237 testLength(11, queue);
237 238
238 Expect.listEquals([9, 1, 5, 9, 10, 1, 5, 9, 10, 1, 5], queue.toList()); 239 Expect.listEquals([9, 1, 5, 9, 10, 1, 5, 9, 10, 1, 5], queue.toList());
239 } 240 }
240 241
241 void testLarge() { 242 void testLarge() {
242 int N = 10000; 243 int N = 10000;
243 Set set = new Set(); 244 Set set = new Set();
244 245
245 Queue queue = newQueue(); 246 Queue queue = newQueue();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 404 }
404 Expect.equals(null, entry2); 405 Expect.equals(null, entry2);
405 } 406 }
406 } 407 }
407 408
408 409
409 main() { 410 main() {
410 new DoubleLinkedQueueTest().testMain(); 411 new DoubleLinkedQueueTest().testMain();
411 new ListQueueTest().testMain(); 412 new ListQueueTest().testMain();
412 } 413 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698