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

Side by Side Diff: tests/corelib/iterable_fold_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 | « sdk/lib/internal/iterable.dart ('k') | tests/corelib/iterable_reduce_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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:typed_data'; 7 import 'dart:typed_data';
8 8
9 class MyList extends ListBase { 9 class MyList extends ListBase {
10 List list; 10 List list;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 testModification(base, modify, transform) { 116 testModification(base, modify, transform) {
117 var iterable = transform(base); 117 var iterable = transform(base);
118 Expect.throws(() { 118 Expect.throws(() {
119 iterable.fold(0, (x, y) { 119 iterable.fold(0, (x, y) {
120 modify(base); 120 modify(base);
121 return x + y; 121 return x + y;
122 }); 122 });
123 }, (e) => e is ConcurrentModificationError); 123 }, (e) => e is ConcurrentModificationError);
124 } 124 }
125 125
126 void add4(collection) { if (collection.length < 10) collection.add(4); } 126 void add4(collection) { collection.add(4); }
127 void addList4(collection) { if (collection.length < 10) collection.add([4]); }
128 void put4(map) { map[4] = 4; } 127 void put4(map) { map[4] = 4; }
129 128
130 testModification([1, 2, 3], add4, id); 129 testModification([1, 2, 3], add4, id);
131 testModification(new HashSet()..add(1)..add(2)..add(3), add4, id); 130 testModification(new HashSet()..add(1)..add(2)..add(3), add4, id);
132 testModification(new LinkedHashSet()..add(1)..add(2)..add(3), add4, id); 131 testModification(new LinkedHashSet()..add(1)..add(2)..add(3), add4, id);
133 testModification(new SplayTreeSet()..add(1)..add(2)..add(3), add4, id); 132 testModification(new SplayTreeSet()..add(1)..add(2)..add(3), add4, id);
134 testModification(new MyList([1, 2, 3]), add4, id); 133 testModification(new MyList([1, 2, 3]), add4, id);
135 134
136 testModification([0, 1, 2, 3], add4, (x) => x.where((x) => x > 0)); 135 testModification([0, 1, 2, 3], add4, (x) => x.where((x) => x > 0));
137 testModification([0, 1, 2], add4, (x) => x.map((x) => x + 1)); 136 testModification([0, 1, 2], add4, (x) => x.map((x) => x + 1));
138 testModification([[1, 2], [3]], addList4, (x) => x.expand((x) => x)); 137 testModification([[1, 2], [3]], add4, (x) => x.expand((x) => x));
139 testModification([3, 2, 1], add4, (x) => x.reversed); 138 testModification([3, 2, 1], add4, (x) => x.reversed);
140 testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.keys); 139 testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.keys);
141 testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.values); 140 testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.values);
142 var hashMap = new HashMap()..[1] = 1..[2] = 2..[3] = 3; 141 var hashMap = new HashMap()..[1] = 1..[2] = 2..[3] = 3;
143 testModification(hashMap, put4, (x) => x.keys); 142 testModification(hashMap, put4, (x) => x.keys);
144 hashMap = new HashMap()..[1] = 1..[2] = 2..[3] = 3; 143 hashMap = new HashMap()..[1] = 1..[2] = 2..[3] = 3;
145 testModification(hashMap, put4, (x) => x.values); 144 testModification(hashMap, put4, (x) => x.values);
146 var splayMap = new SplayTreeMap()..[1] = 1..[2] = 2..[3] = 3; 145 var splayMap = new SplayTreeMap()..[1] = 1..[2] = 2..[3] = 3;
147 testModification(splayMap, put4, (x) => x.keys); 146 testModification(splayMap, put4, (x) => x.keys);
148 splayMap = new SplayTreeMap()..[1] = 1..[2] = 2..[3] = 3; 147 splayMap = new SplayTreeMap()..[1] = 1..[2] = 2..[3] = 3;
149 testModification(splayMap, put4, (x) => x.values); 148 testModification(splayMap, put4, (x) => x.values);
150 } 149 }
OLDNEW
« no previous file with comments | « sdk/lib/internal/iterable.dart ('k') | tests/corelib/iterable_reduce_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698