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

Side by Side Diff: test/dart_codegen/expect/collection/list.dart

Issue 959073002: Fix new line breaks on } (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 part of dart.collection; 1 part of dart.collection;
2 abstract class ListBase<E> extends Object with ListMixin<E> {static String list ToString(List list) => IterableBase.iterableToFullString(list, '[', ']'); 2 abstract class ListBase<E> extends Object with ListMixin<E> {static String list ToString(List list) => IterableBase.iterableToFullString(list, '[', ']');
3 } 3 }
4 abstract class ListMixin<E> implements List<E> {Iterator<E> get iterator => new ListIterator<E>(this); 4 abstract class ListMixin<E> implements List<E> {Iterator<E> get iterator => new ListIterator<E>(this);
5 E elementAt(int index) => this[index]; 5 E elementAt(int index) => this[index];
6 void forEach(void action(E element)) { 6 void forEach(void action(E element)) {
7 int length = this.length; 7 int length = this.length;
8 for (int i = 0; 8 for (int i = 0; i < length; i++) {
9 i < length;
10 i++) {
11 action(this[i]); 9 action(this[i]);
12 if (length != this.length) { 10 if (length != this.length) {
13 throw new ConcurrentModificationError(this); 11 throw new ConcurrentModificationError(this);
14 } 12 }
15 } 13 }
16 } 14 }
17 bool get isEmpty => length == 0; 15 bool get isEmpty => length == 0;
18 bool get isNotEmpty => !isEmpty; 16 bool get isNotEmpty => !isEmpty;
19 E get first { 17 E get first {
20 if (length == 0) throw IterableElementError.noElement(); 18 if (length == 0) throw IterableElementError.noElement();
21 return this[0]; 19 return this[0];
22 } 20 }
23 E get last { 21 E get last {
24 if (length == 0) throw IterableElementError.noElement(); 22 if (length == 0) throw IterableElementError.noElement();
25 return this[length - 1]; 23 return this[length - 1];
26 } 24 }
27 E get single { 25 E get single {
28 if (length == 0) throw IterableElementError.noElement(); 26 if (length == 0) throw IterableElementError.noElement();
29 if (length > 1) throw IterableElementError.tooMany(); 27 if (length > 1) throw IterableElementError.tooMany();
30 return this[0]; 28 return this[0];
31 } 29 }
32 bool contains(Object element) { 30 bool contains(Object element) {
33 int length = this.length; 31 int length = this.length;
34 for (int i = 0; 32 for (int i = 0; i < this.length; i++) {
35 i < this.length;
36 i++) {
37 if (this[i] == element) return true; 33 if (this[i] == element) return true;
38 if (length != this.length) { 34 if (length != this.length) {
39 throw new ConcurrentModificationError(this); 35 throw new ConcurrentModificationError(this);
40 } 36 }
41 } 37 }
42 return false; 38 return false;
43 } 39 }
44 bool every(bool test(E element)) { 40 bool every(bool test(E element)) {
45 int length = this.length; 41 int length = this.length;
46 for (int i = 0; 42 for (int i = 0; i < length; i++) {
47 i < length;
48 i++) {
49 if (!test(this[i])) return false; 43 if (!test(this[i])) return false;
50 if (length != this.length) { 44 if (length != this.length) {
51 throw new ConcurrentModificationError(this); 45 throw new ConcurrentModificationError(this);
52 } 46 }
53 } 47 }
54 return true; 48 return true;
55 } 49 }
56 bool any(bool test(E element)) { 50 bool any(bool test(E element)) {
57 int length = this.length; 51 int length = this.length;
58 for (int i = 0; 52 for (int i = 0; i < length; i++) {
59 i < length;
60 i++) {
61 if (test(this[i])) return true; 53 if (test(this[i])) return true;
62 if (length != this.length) { 54 if (length != this.length) {
63 throw new ConcurrentModificationError(this); 55 throw new ConcurrentModificationError(this);
64 } 56 }
65 } 57 }
66 return false; 58 return false;
67 } 59 }
68 E firstWhere(bool test(E element), { 60 E firstWhere(bool test(E element), {
69 E orElse()} 61 E orElse()}
70 ) { 62 ) {
71 int length = this.length; 63 int length = this.length;
72 for (int i = 0; 64 for (int i = 0; i < length; i++) {
73 i < length;
74 i++) {
75 E element = this[i]; 65 E element = this[i];
76 if (test(element)) return element; 66 if (test(element)) return element;
77 if (length != this.length) { 67 if (length != this.length) {
78 throw new ConcurrentModificationError(this); 68 throw new ConcurrentModificationError(this);
79 } 69 }
80 } 70 }
81 if (orElse != null) return orElse(); 71 if (orElse != null) return orElse();
82 throw IterableElementError.noElement(); 72 throw IterableElementError.noElement();
83 } 73 }
84 E lastWhere(bool test(E element), { 74 E lastWhere(bool test(E element), {
85 E orElse()} 75 E orElse()}
86 ) { 76 ) {
87 int length = this.length; 77 int length = this.length;
88 for (int i = length - 1; 78 for (int i = length - 1; i >= 0; i--) {
89 i >= 0;
90 i--) {
91 E element = this[i]; 79 E element = this[i];
92 if (test(element)) return element; 80 if (test(element)) return element;
93 if (length != this.length) { 81 if (length != this.length) {
94 throw new ConcurrentModificationError(this); 82 throw new ConcurrentModificationError(this);
95 } 83 }
96 } 84 }
97 if (orElse != null) return orElse(); 85 if (orElse != null) return orElse();
98 throw IterableElementError.noElement(); 86 throw IterableElementError.noElement();
99 } 87 }
100 E singleWhere(bool test(E element)) { 88 E singleWhere(bool test(E element)) {
101 int length = this.length; 89 int length = this.length;
102 E match = ((__x9) => DDC$RT.cast(__x9, Null, E, "CastLiteral", """line 151, col umn 15 of dart:collection/list.dart: """, __x9 is E, false))(null); 90 E match = ((__x9) => DDC$RT.cast(__x9, Null, E, "CastLiteral", """line 151, col umn 15 of dart:collection/list.dart: """, __x9 is E, false))(null);
103 bool matchFound = false; 91 bool matchFound = false;
104 for (int i = 0; 92 for (int i = 0; i < length; i++) {
105 i < length;
106 i++) {
107 E element = this[i]; 93 E element = this[i];
108 if (test(element)) { 94 if (test(element)) {
109 if (matchFound) { 95 if (matchFound) {
110 throw IterableElementError.tooMany(); 96 throw IterableElementError.tooMany();
111 } 97 }
112 matchFound = true; 98 matchFound = true;
113 match = element; 99 match = element;
114 } 100 }
115 if (length != this.length) { 101 if (length != this.length) {
116 throw new ConcurrentModificationError(this); 102 throw new ConcurrentModificationError(this);
117 } 103 }
118 } 104 }
119 if (matchFound) return match; 105 if (matchFound) return match;
120 throw IterableElementError.noElement(); 106 throw IterableElementError.noElement();
121 } 107 }
122 String join([String separator = ""]) { 108 String join([String separator = ""]) {
123 if (length == 0) return ""; 109 if (length == 0) return "";
124 StringBuffer buffer = new StringBuffer()..writeAll(this, separator); 110 StringBuffer buffer = new StringBuffer()..writeAll(this, separator);
125 return buffer.toString(); 111 return buffer.toString();
126 } 112 }
127 Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test); 113 Iterable<E> where(bool test(E element)) => new WhereIterable<E>(this, test);
128 Iterable map(f(E element)) => new MappedListIterable(this, f); 114 Iterable map(f(E element)) => new MappedListIterable(this, f);
129 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this, f); 115 Iterable expand(Iterable f(E element)) => new ExpandIterable<E, dynamic>(this, f);
130 E reduce(E combine(E previousValue, E element)) { 116 E reduce(E combine(E previousValue, E element)) {
131 int length = this.length; 117 int length = this.length;
132 if (length == 0) throw IterableElementError.noElement(); 118 if (length == 0) throw IterableElementError.noElement();
133 E value = this[0]; 119 E value = this[0];
134 for (int i = 1; 120 for (int i = 1; i < length; i++) {
135 i < length;
136 i++) {
137 value = combine(value, this[i]); 121 value = combine(value, this[i]);
138 if (length != this.length) { 122 if (length != this.length) {
139 throw new ConcurrentModificationError(this); 123 throw new ConcurrentModificationError(this);
140 } 124 }
141 } 125 }
142 return value; 126 return value;
143 } 127 }
144 fold(var initialValue, combine(var previousValue, E element)) { 128 fold(var initialValue, combine(var previousValue, E element)) {
145 var value = initialValue; 129 var value = initialValue;
146 int length = this.length; 130 int length = this.length;
147 for (int i = 0; 131 for (int i = 0; i < length; i++) {
148 i < length;
149 i++) {
150 value = combine(value, this[i]); 132 value = combine(value, this[i]);
151 if (length != this.length) { 133 if (length != this.length) {
152 throw new ConcurrentModificationError(this); 134 throw new ConcurrentModificationError(this);
153 } 135 }
154 } 136 }
155 return value; 137 return value;
156 } 138 }
157 Iterable<E> skip(int count) => new SubListIterable<E>(this, count, null); 139 Iterable<E> skip(int count) => new SubListIterable<E>(this, count, null);
158 Iterable<E> skipWhile(bool test(E element)) { 140 Iterable<E> skipWhile(bool test(E element)) {
159 return new SkipWhileIterable<E>(this, test); 141 return new SkipWhileIterable<E>(this, test);
160 } 142 }
161 Iterable<E> take(int count) => new SubListIterable<E>(this, 0, count); 143 Iterable<E> take(int count) => new SubListIterable<E>(this, 0, count);
162 Iterable<E> takeWhile(bool test(E element)) { 144 Iterable<E> takeWhile(bool test(E element)) {
163 return new TakeWhileIterable<E>(this, test); 145 return new TakeWhileIterable<E>(this, test);
164 } 146 }
165 List<E> toList({ 147 List<E> toList({
166 bool growable : true} 148 bool growable : true}
167 ) { 149 ) {
168 List<E> result; 150 List<E> result;
169 if (growable) { 151 if (growable) {
170 result = new List<E>()..length = length; 152 result = new List<E>()..length = length;
171 } 153 }
172 else { 154 else {
173 result = new List<E>(length); 155 result = new List<E>(length);
174 } 156 }
175 for (int i = 0; 157 for (int i = 0; i < length; i++) {
176 i < length;
177 i++) {
178 result[i] = this[i]; 158 result[i] = this[i];
179 } 159 }
180 return result; 160 return result;
181 } 161 }
182 Set<E> toSet() { 162 Set<E> toSet() {
183 Set<E> result = new Set<E>(); 163 Set<E> result = new Set<E>();
184 for (int i = 0; 164 for (int i = 0; i < length; i++) {
185 i < length;
186 i++) {
187 result.add(this[i]); 165 result.add(this[i]);
188 } 166 }
189 return result; 167 return result;
190 } 168 }
191 void add(E element) { 169 void add(E element) {
192 this[this.length++] = element; 170 this[this.length++] = element;
193 } 171 }
194 void addAll(Iterable<E> iterable) { 172 void addAll(Iterable<E> iterable) {
195 for (E element in iterable) { 173 for (E element in iterable) {
196 this[this.length++] = element; 174 this[this.length++] = element;
197 } 175 }
198 } 176 }
199 bool remove(Object element) { 177 bool remove(Object element) {
200 for (int i = 0; 178 for (int i = 0; i < this.length; i++) {
201 i < this.length;
202 i++) {
203 if (this[i] == element) { 179 if (this[i] == element) {
204 this.setRange(i, this.length - 1, this, i + 1); 180 this.setRange(i, this.length - 1, this, i + 1);
205 this.length -= 1; 181 this.length -= 1;
206 return true; 182 return true;
207 } 183 }
208 } 184 }
209 return false; 185 return false;
210 } 186 }
211 void removeWhere(bool test(E element)) { 187 void removeWhere(bool test(E element)) {
212 _filter(this, DDC$RT.wrap((bool f(E __u10)) { 188 _filter(this, DDC$RT.wrap((bool f(E __u10)) {
213 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 264, column 19 of dart:collection/list.dart: """, x0 is E, false)); 189 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 264, column 19 of dart:collection/list.dart: """, x0 is E, false));
214 return f == null ? null : c; 190 return f == null ? null : c;
215 } 191 }
216 , test, DDC$RT.type((__t13<E> _) { 192 , test, DDC$RT.type((__t13<E> _) {
217 } 193 }
218 ), __t11, "Wrap", """line 264, column 19 of dart:collection/list.dart: """, test is __t11), false); 194 ), __t11, "Wrap", """line 264, column 19 of dart:collection/list.dart: """, test is __t11), false);
219 } 195 }
220 void retainWhere(bool test(E element)) { 196 void retainWhere(bool test(E element)) {
221 _filter(this, DDC$RT.wrap((bool f(E __u15)) { 197 _filter(this, DDC$RT.wrap((bool f(E __u15)) {
222 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 268, column 19 of dart:collection/list.dart: """, x0 is E, false)); 198 bool c(E x0) => f(DDC$RT.cast(x0, dynamic, E, "CastParam", """line 268, column 19 of dart:collection/list.dart: """, x0 is E, false));
223 return f == null ? null : c; 199 return f == null ? null : c;
224 } 200 }
225 , test, DDC$RT.type((__t13<E> _) { 201 , test, DDC$RT.type((__t13<E> _) {
226 } 202 }
227 ), __t11, "Wrap", """line 268, column 19 of dart:collection/list.dart: """, test is __t11), true); 203 ), __t11, "Wrap", """line 268, column 19 of dart:collection/list.dart: """, test is __t11), true);
228 } 204 }
229 static void _filter(List source, bool test(var element), bool retainMatching) { 205 static void _filter(List source, bool test(var element), bool retainMatching) {
230 List retained = []; 206 List retained = [];
231 int length = source.length; 207 int length = source.length;
232 for (int i = 0; 208 for (int i = 0; i < length; i++) {
233 i < length;
234 i++) {
235 var element = source[i]; 209 var element = source[i];
236 if (test(element) == retainMatching) { 210 if (test(element) == retainMatching) {
237 retained.add(element); 211 retained.add(element);
238 } 212 }
239 if (length != source.length) { 213 if (length != source.length) {
240 throw new ConcurrentModificationError(source); 214 throw new ConcurrentModificationError(source);
241 } 215 }
242 } 216 }
243 if (retained.length != source.length) { 217 if (retained.length != source.length) {
244 source.setRange(0, retained.length, retained); 218 source.setRange(0, retained.length, retained);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 256 }
283 Map<int, E> asMap() { 257 Map<int, E> asMap() {
284 return new ListMapView<E>(this); 258 return new ListMapView<E>(this);
285 } 259 }
286 List<E> sublist(int start, [int end]) { 260 List<E> sublist(int start, [int end]) {
287 int listLength = this.length; 261 int listLength = this.length;
288 if (end == null) end = listLength; 262 if (end == null) end = listLength;
289 RangeError.checkValidRange(start, end, listLength); 263 RangeError.checkValidRange(start, end, listLength);
290 int length = end - start; 264 int length = end - start;
291 List<E> result = new List<E>()..length = length; 265 List<E> result = new List<E>()..length = length;
292 for (int i = 0; 266 for (int i = 0; i < length; i++) {
293 i < length;
294 i++) {
295 result[i] = this[start + i]; 267 result[i] = this[start + i];
296 } 268 }
297 return result; 269 return result;
298 } 270 }
299 Iterable<E> getRange(int start, int end) { 271 Iterable<E> getRange(int start, int end) {
300 RangeError.checkValidRange(start, end, this.length); 272 RangeError.checkValidRange(start, end, this.length);
301 return new SubListIterable<E>(this, start, end); 273 return new SubListIterable<E>(this, start, end);
302 } 274 }
303 void removeRange(int start, int end) { 275 void removeRange(int start, int end) {
304 RangeError.checkValidRange(start, end, this.length); 276 RangeError.checkValidRange(start, end, this.length);
305 int length = end - start; 277 int length = end - start;
306 setRange(start, this.length - length, this, end); 278 setRange(start, this.length - length, this, end);
307 this.length -= length; 279 this.length -= length;
308 } 280 }
309 void fillRange(int start, int end, [E fill]) { 281 void fillRange(int start, int end, [E fill]) {
310 RangeError.checkValidRange(start, end, this.length); 282 RangeError.checkValidRange(start, end, this.length);
311 for (int i = start; 283 for (int i = start; i < end; i++) {
312 i < end;
313 i++) {
314 this[i] = fill; 284 this[i] = fill;
315 } 285 }
316 } 286 }
317 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { 287 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
318 RangeError.checkValidRange(start, end, this.length); 288 RangeError.checkValidRange(start, end, this.length);
319 int length = end - start; 289 int length = end - start;
320 if (length == 0) return; RangeError.checkNotNegative(skipCount, "skipCount"); 290 if (length == 0) return; RangeError.checkNotNegative(skipCount, "skipCount");
321 List otherList; 291 List otherList;
322 int otherStart; 292 int otherStart;
323 if (iterable is List) { 293 if (iterable is List) {
324 otherList = DDC$RT.cast(iterable, DDC$RT.type((Iterable<E> _) { 294 otherList = DDC$RT.cast(iterable, DDC$RT.type((Iterable<E> _) {
325 } 295 }
326 ), DDC$RT.type((List<dynamic> _) { 296 ), DDC$RT.type((List<dynamic> _) {
327 } 297 }
328 ), "CastGeneral", """line 369, column 19 of dart:collection/list.dart: """, it erable is List<dynamic>, true); 298 ), "CastGeneral", """line 369, column 19 of dart:collection/list.dart: """, it erable is List<dynamic>, true);
329 otherStart = skipCount; 299 otherStart = skipCount;
330 } 300 }
331 else { 301 else {
332 otherList = iterable.skip(skipCount).toList(growable: false); 302 otherList = iterable.skip(skipCount).toList(growable: false);
333 otherStart = 0; 303 otherStart = 0;
334 } 304 }
335 if (otherStart + length > otherList.length) { 305 if (otherStart + length > otherList.length) {
336 throw IterableElementError.tooFew(); 306 throw IterableElementError.tooFew();
337 } 307 }
338 if (otherStart < start) { 308 if (otherStart < start) {
339 for (int i = length - 1; 309 for (int i = length - 1; i >= 0; i--) {
340 i >= 0;
341 i--) {
342 this[start + i] = ((__x24) => DDC$RT.cast(__x24, dynamic, E, "CastGeneral", """line 381, column 27 of dart:collection/list.dart: """, __x24 is E, false))(ot herList[otherStart + i]); 310 this[start + i] = ((__x24) => DDC$RT.cast(__x24, dynamic, E, "CastGeneral", """line 381, column 27 of dart:collection/list.dart: """, __x24 is E, false))(ot herList[otherStart + i]);
343 } 311 }
344 } 312 }
345 else { 313 else {
346 for (int i = 0; 314 for (int i = 0; i < length; i++) {
347 i < length;
348 i++) {
349 this[start + i] = ((__x25) => DDC$RT.cast(__x25, dynamic, E, "CastGeneral", """line 385, column 27 of dart:collection/list.dart: """, __x25 is E, false))(ot herList[otherStart + i]); 315 this[start + i] = ((__x25) => DDC$RT.cast(__x25, dynamic, E, "CastGeneral", """line 385, column 27 of dart:collection/list.dart: """, __x25 is E, false))(ot herList[otherStart + i]);
350 } 316 }
351 } 317 }
352 } 318 }
353 void replaceRange(int start, int end, Iterable<E> newContents) { 319 void replaceRange(int start, int end, Iterable<E> newContents) {
354 RangeError.checkValidRange(start, end, this.length); 320 RangeError.checkValidRange(start, end, this.length);
355 if (newContents is! EfficientLength) { 321 if (newContents is! EfficientLength) {
356 newContents = newContents.toList(); 322 newContents = newContents.toList();
357 } 323 }
358 int removeLength = end - start; 324 int removeLength = end - start;
(...skipping 17 matching lines...) Expand all
376 this.setRange(start, insertEnd, newContents); 342 this.setRange(start, insertEnd, newContents);
377 } 343 }
378 } 344 }
379 int indexOf(Object element, [int startIndex = 0]) { 345 int indexOf(Object element, [int startIndex = 0]) {
380 if (startIndex >= this.length) { 346 if (startIndex >= this.length) {
381 return -1; 347 return -1;
382 } 348 }
383 if (startIndex < 0) { 349 if (startIndex < 0) {
384 startIndex = 0; 350 startIndex = 0;
385 } 351 }
386 for (int i = startIndex; 352 for (int i = startIndex; i < this.length; i++) {
387 i < this.length;
388 i++) {
389 if (this[i] == element) { 353 if (this[i] == element) {
390 return i; 354 return i;
391 } 355 }
392 } 356 }
393 return -1; 357 return -1;
394 } 358 }
395 int lastIndexOf(Object element, [int startIndex]) { 359 int lastIndexOf(Object element, [int startIndex]) {
396 if (startIndex == null) { 360 if (startIndex == null) {
397 startIndex = this.length - 1; 361 startIndex = this.length - 1;
398 } 362 }
399 else { 363 else {
400 if (startIndex < 0) { 364 if (startIndex < 0) {
401 return -1; 365 return -1;
402 } 366 }
403 if (startIndex >= this.length) { 367 if (startIndex >= this.length) {
404 startIndex = this.length - 1; 368 startIndex = this.length - 1;
405 } 369 }
406 } 370 }
407 for (int i = startIndex; 371 for (int i = startIndex; i >= 0; i--) {
408 i >= 0;
409 i--) {
410 if (this[i] == element) { 372 if (this[i] == element) {
411 return i; 373 return i;
412 } 374 }
413 } 375 }
414 return -1; 376 return -1;
415 } 377 }
416 void insert(int index, E element) { 378 void insert(int index, E element) {
417 RangeError.checkValueInInterval(index, 0, length, "index"); 379 RangeError.checkValueInInterval(index, 0, length, "index");
418 if (index == this.length) { 380 if (index == this.length) {
419 add(element); 381 add(element);
(...skipping 29 matching lines...) Expand all
449 } 411 }
450 } 412 }
451 } 413 }
452 Iterable<E> get reversed => new ReversedListIterable<E>(this); 414 Iterable<E> get reversed => new ReversedListIterable<E>(this);
453 String toString() => IterableBase.iterableToFullString(this, '[', ']'); 415 String toString() => IterableBase.iterableToFullString(this, '[', ']');
454 } 416 }
455 typedef bool __t11(dynamic __u12); 417 typedef bool __t11(dynamic __u12);
456 typedef bool __t13<E>(E __u14); 418 typedef bool __t13<E>(E __u14);
457 typedef int __t18(dynamic __u19, dynamic __u20); 419 typedef int __t18(dynamic __u19, dynamic __u20);
458 typedef int __t21<E>(E __u22, E __u23); 420 typedef int __t21<E>(E __u22, E __u23);
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/collection/iterable.dart ('k') | test/dart_codegen/expect/collection/queue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698