| 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 library queue.test; | 5 library queue.test; |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 abstract class QueueTest { | 10 abstract class QueueTest { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 230 |
| 231 queue.removeWhere((x) => x == 7); | 231 queue.removeWhere((x) => x == 7); |
| 232 testLength(26, queue); | 232 testLength(26, queue); |
| 233 | 233 |
| 234 queue.retainWhere((x) => x != 3); | 234 queue.retainWhere((x) => x != 3); |
| 235 testLength(23, queue); | 235 testLength(23, queue); |
| 236 | 236 |
| 237 Expect.listEquals( | 237 Expect.listEquals( |
| 238 [6, 8, 9, 1, 2, 4, 5, 6, 8, 9, 10, 1, 2, 4, 5, 6, 8, 9, 10, 1, 2, 4, 5], | 238 [6, 8, 9, 1, 2, 4, 5, 6, 8, 9, 10, 1, 2, 4, 5, 6, 8, 9, 10, 1, 2, 4, 5], |
| 239 queue.toList()); | 239 queue.toList()); |
| 240 |
| 241 // Regression test: http://dartbug.com/16270 |
| 242 // These should all do nothing, and should not throw. |
| 243 Queue emptyQueue = newQueue(); |
| 244 emptyQueue.remove(0); |
| 245 emptyQueue.removeWhere((x) => null); |
| 246 emptyQueue.retainWhere((x) => null); |
| 240 } | 247 } |
| 241 | 248 |
| 242 void testLarge() { | 249 void testLarge() { |
| 243 int N = 10000; | 250 int N = 10000; |
| 244 Set set = new Set(); | 251 Set set = new Set(); |
| 245 | 252 |
| 246 Queue queue = newQueue(); | 253 Queue queue = newQueue(); |
| 247 Expect.isTrue(queue.isEmpty); | 254 Expect.isTrue(queue.isEmpty); |
| 248 | 255 |
| 249 for (int i = 0; i < N; i++) { | 256 for (int i = 0; i < N; i++) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 } | 408 } |
| 402 Expect.equals(null, entry2); | 409 Expect.equals(null, entry2); |
| 403 } | 410 } |
| 404 } | 411 } |
| 405 | 412 |
| 406 | 413 |
| 407 main() { | 414 main() { |
| 408 new DoubleLinkedQueueTest().testMain(); | 415 new DoubleLinkedQueueTest().testMain(); |
| 409 new ListQueueTest().testMain(); | 416 new ListQueueTest().testMain(); |
| 410 } | 417 } |
| OLD | NEW |