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

Side by Side Diff: tests/corelib_strong/iterable_skip_test.dart

Issue 2683893002: Make corelib_strong tests strong-mode compliant (Closed)
Patch Set: Created 3 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 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 6
7 main() { 7 main() {
8 List<int> list1 = <int>[1, 2, 3]; 8 List<int> list1 = <int>[1, 2, 3];
9 List<int> list2 = const <int>[4, 5]; 9 List<int> list2 = const <int>[4, 5];
10 List<String> list3 = <String>[]; 10 List<String> list3 = <String>[];
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 Expect.isNull(it.current); 208 Expect.isNull(it.current);
209 Expect.isFalse(it.moveNext()); 209 Expect.isFalse(it.moveNext());
210 Expect.isNull(it.current); 210 Expect.isNull(it.current);
211 211
212 skip4 = set1.skip(4); 212 skip4 = set1.skip(4);
213 it = skip4.iterator; 213 it = skip4.iterator;
214 Expect.isNull(it.current); 214 Expect.isNull(it.current);
215 Expect.isFalse(it.moveNext()); 215 Expect.isFalse(it.moveNext());
216 Expect.isNull(it.current); 216 Expect.isNull(it.current);
217 217
218 skip0 = set2.skip(0); 218 var dynamicSkip0 = set2.skip(0);
Leaf 2017/02/08 02:03:49 Alternatively, could make the set2 declaration be
219 it = skip0.iterator; 219 var dynamicIt = dynamicSkip0.iterator;
220 Expect.isNull(it.current); 220 Expect.isNull(dynamicIt.current);
221 Expect.isFalse(it.moveNext()); 221 Expect.isFalse(dynamicIt.moveNext());
222 Expect.isNull(it.current); 222 Expect.isNull(dynamicIt.current);
223 223
224 skip1 = set2.skip(1); 224 var dynamicSkip1 = set2.skip(1);
225 it = skip1.iterator; 225 dynamicIt = dynamicSkip1.iterator;
226 Expect.isNull(it.current); 226 Expect.isNull(dynamicIt.current);
227 Expect.isFalse(it.moveNext()); 227 Expect.isFalse(dynamicIt.moveNext());
228 Expect.isNull(it.current); 228 Expect.isNull(dynamicIt.current);
229 229
230 testSkipTake(Iterable input, int skip, int take) { 230 testSkipTake(Iterable input, int skip, int take) {
231 List expected = []; 231 List expected = [];
232 Iterator iter = input.iterator; 232 Iterator iter = input.iterator;
233 for (int i = 0; i < skip; i++) iter.moveNext(); 233 for (int i = 0; i < skip; i++) iter.moveNext();
234 for (int i = 0; i < take; i++) { 234 for (int i = 0; i < take; i++) {
235 if (!iter.moveNext()) break; 235 if (!iter.moveNext()) break;
236 expected.add(iter.current); 236 expected.add(iter.current);
237 } 237 }
238 Expect.listEquals(expected, input.skip(skip).take(take).toList()); 238 Expect.listEquals(expected, input.skip(skip).take(take).toList());
(...skipping 11 matching lines...) Expand all
250 testSkipTake(collection, 5, 5); 250 testSkipTake(collection, 5, 5);
251 testSkipTake(collection, 5, 10); 251 testSkipTake(collection, 5, 10);
252 testSkipTake(collection, 5, 20); 252 testSkipTake(collection, 5, 20);
253 testSkipTake(collection, 15, 0); 253 testSkipTake(collection, 15, 0);
254 testSkipTake(collection, 15, 5); 254 testSkipTake(collection, 15, 5);
255 testSkipTake(collection, 20, 0); 255 testSkipTake(collection, 20, 0);
256 testSkipTake(collection, 20, 5); 256 testSkipTake(collection, 20, 5);
257 Expect.throws(() => longList.skip(-1), (e) => e is RangeError); 257 Expect.throws(() => longList.skip(-1), (e) => e is RangeError);
258 } 258 }
259 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698