[tests] Remove more deprecated List constructor usage in tests

Change-Id: I9a6da832ee51f9362bb2ea4f17931a109b36456e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142721
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
This commit is contained in:
Riley Porter 2020-04-07 20:09:26 +00:00 committed by commit-bot@chromium.org
parent 40b4389891
commit ed086f0f95
5 changed files with 14 additions and 15 deletions

View file

@ -51,8 +51,9 @@ class CallbackIterator implements Iterator<int> {
}
_current = _nextIndex;
_nextIndex++;
if (_current == _iterable.callbackIndex) {
_iterable.callback();
var tempCallback = _iterable.callback;
if (_current == _iterable.callbackIndex && tempCallback != null) {
tempCallback();
}
return true;
}
@ -83,21 +84,19 @@ void testConstructor() {
Expect.throws(fn, (_) => true, name);
}
testFixedLength(new List<int?>(0));
testFixedLength(new List<int?>(5));
testFixedLength(new List<int?>.empty());
testFixedLength(new List<int?>.filled(5, null)); // default growable: false.
testGrowable(new List<int?>());
testGrowable(new List<int?>()..length = 5);
testGrowable(<int?>[]);
testGrowable(<int?>[]..length = 5);
testGrowable(new List<int?>.filled(5, null, growable: true));
Expect.throwsArgumentError(() => new List<int?>(-1), "-1");
Expect.throwsArgumentError(() => new List<int?>.filled(-1, null), "-1");
// There must be limits. Fix this test if we ever allow 2^63 elements.
Expect.throws(() => new List<int?>(0x7ffffffffffff000),
Expect.throws(() => new List<int?>.filled(0x7ffffffffffff000, null),
(e) => e is OutOfMemoryError || e is ArgumentError, "bignum");
Expect.throwsArgumentError(() => new List<int?>(null), "null");
testThrowsOrTypeError(
() => new List([] as dynamic), // Cast to avoid warning.
() => new List.filled([] as dynamic, null), // Cast to avoid warning.
'list');
testThrowsOrTypeError(() => new List([42] as dynamic), "list2");
testThrowsOrTypeError(() => new List.filled([42] as dynamic, null), "list2");
}
void testConcurrentModification() {

View file

@ -177,7 +177,7 @@ void testInts(Set create()) {
}
// Test Set.addAll.
List list = new List(10);
List list = new List.filled(10, null);
for (int i = 0; i < 10; i++) {
list[i] = i + 10;
}

View file

@ -15,7 +15,7 @@ main() {
}
testInt64List() {
var array = new List(10);
var array = new List<int?>.filled(10, null);
testInt64ListImpl(array);
}

View file

@ -12,7 +12,7 @@
// VMOptions=--enable_asserts
main() {
var names = new List<int>();
var names = <int>[];
// Generic type test.
assert(names is List<int>);

View file

@ -89,7 +89,7 @@ class DataProvider {
listSize -= sentCount - targetCount;
sentCount = targetCount;
}
controller.add(new List(listSize));
controller.add(new List.filled(listSize, null));
int ms = listSize * 1000 ~/ bytesPerSecond;
Duration duration = new Duration(milliseconds: ms);
if (!controller.isPaused) {