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

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

Issue 1064053007: Revert "Change ListIterator to only check for concurrent modification at each iteration" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | « tests/corelib/json_map_test.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
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 import "dart:collection"; 5 import "dart:collection";
6 import "dart:typed_data"; 6 import "dart:typed_data";
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 void main() { 9 void main() {
10 // Typed lists - fixed length and can only contain integers. 10 // Typed lists - fixed length and can only contain integers.
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 369
370 list.replaceRange(2, 3, [5, 5, 5]); 370 list.replaceRange(2, 3, [5, 5, 5]);
371 Expect.listEquals([1, 2, 5, 5, 5, 0, 0, 7, 2, 3, 2, 1], list); 371 Expect.listEquals([1, 2, 5, 5, 5, 0, 0, 7, 2, 3, 2, 1], list);
372 372
373 list.replaceRange(2, 4, [6, 6]); 373 list.replaceRange(2, 4, [6, 6]);
374 Expect.listEquals([1, 2, 6, 6, 5, 0, 0, 7, 2, 3, 2, 1], list); 374 Expect.listEquals([1, 2, 6, 6, 5, 0, 0, 7, 2, 3, 2, 1], list);
375 375
376 list.replaceRange(6, 8, []); 376 list.replaceRange(6, 8, []);
377 Expect.listEquals([1, 2, 6, 6, 5, 0, 2, 3, 2, 1], list); 377 Expect.listEquals([1, 2, 6, 6, 5, 0, 2, 3, 2, 1], list);
378 378
379 // Operations that change the length may cause ConcurrentModificationError. 379 // Operations that change the length cause ConcurrentModificationError.
380 // Reducing the length may cause a RangeError before the
381 // ConcurrentModificationError in production mode.
382 bool checkedMode = false;
383 assert((checkedMode = true));
384
385 void testConcurrentModification(action()) { 380 void testConcurrentModification(action()) {
386 testIterator(int when) { 381 testIterator(int when) {
387 list.length = 4; 382 list.length = 4;
388 list.setAll(0, [0, 1, 2, 3]); 383 list.setAll(0, [0, 1, 2, 3]);
389 Expect.throws(() { 384 Expect.throws(() {
390 for (var element in list) { 385 for (var element in list) {
391 if (element == when) { 386 if (element == when) action();
392 when = -1; // Prevent triggering more than once.
393 action();
394 }
395 } 387 }
396 }, (e) => !checkedMode || e is ConcurrentModificationError); 388 }, (e) => e is ConcurrentModificationError);
397 } 389 }
398 testForEach(int when) { 390 testForEach(int when) {
399 list.length = 4; 391 list.length = 4;
400 list.setAll(0, [0, 1, 2, 3]); 392 list.setAll(0, [0, 1, 2, 3]);
401 Expect.throws(() { 393 Expect.throws(() {
402 list.forEach((var element) { 394 list.forEach((var element) {
403 if (element == when) { 395 if (element == when) action();
404 when = -1;
405 action();
406 }
407 }); 396 });
408 }, (e) => e is ConcurrentModificationError); 397 }, (e) => e is ConcurrentModificationError);
409 } 398 }
410 // Test the change at different points of the iteration. 399 // Test the change at different points of the iteration.
411 testIterator(0); 400 testIterator(0);
412 testIterator(1); 401 testIterator(1);
413 testIterator(3); 402 testIterator(3);
414 testForEach(0); 403 testForEach(0);
415 testForEach(1); 404 testForEach(1);
416 testForEach(3); 405 testForEach(3);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 497
509 void testListConstructor() { 498 void testListConstructor() {
510 Expect.throws(() { new List(0).add(4); }); // Is fixed-length. 499 Expect.throws(() { new List(0).add(4); }); // Is fixed-length.
511 Expect.throws(() { new List(-2); }); // Not negative. /// 01: ok 500 Expect.throws(() { new List(-2); }); // Not negative. /// 01: ok
512 Expect.throws(() { new List(null); }); // Not null. 501 Expect.throws(() { new List(null); }); // Not null.
513 Expect.listEquals([4], new List()..add(4)); 502 Expect.listEquals([4], new List()..add(4));
514 Expect.throws(() { new List.filled(0, 42).add(4); }); // Is fixed-length. 503 Expect.throws(() { new List.filled(0, 42).add(4); }); // Is fixed-length.
515 Expect.throws(() { new List.filled(-2, 42); }); // Not negative. 504 Expect.throws(() { new List.filled(-2, 42); }); // Not negative.
516 Expect.throws(() { new List.filled(null, 42); }); // Not null. 505 Expect.throws(() { new List.filled(null, 42); }); // Not null.
517 } 506 }
OLDNEW
« no previous file with comments | « tests/corelib/json_map_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698