mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:31:50 +00:00
[3.0 alpha] Remove deprecated dart:core List() constructor.
TEST=ci Bug: Contributes to https://github.com/dart-lang/sdk/issues/49529 Change-Id: Ic129ef2d89f625d9ec6a7a1c301cffddd60b2ff7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258920 Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Michael Thomsen <mit@google.com> Reviewed-by: Slava Egorov <vegorov@google.com>
This commit is contained in:
parent
7ebd4dd61c
commit
e4cc3c98e5
|
@ -10,12 +10,6 @@
|
|||
|
||||
namespace dart {
|
||||
|
||||
DEFINE_NATIVE_ENTRY(List_new, 0, 2) {
|
||||
// This function is handled by flow-graph builder.
|
||||
UNREACHABLE();
|
||||
return Object::null();
|
||||
}
|
||||
|
||||
DEFINE_NATIVE_ENTRY(List_allocate, 0, 2) {
|
||||
// Implemented in FlowGraphBuilder::VisitNativeBody.
|
||||
UNREACHABLE();
|
||||
|
|
|
@ -946,7 +946,7 @@ class _SnapshotGraph implements SnapshotGraph {
|
|||
|
||||
var internalSizes = _newUint32Array(N + 1);
|
||||
var cids = _newUint16Array(N + 1);
|
||||
var nonReferenceData = new List(N + 1);
|
||||
var nonReferenceData = List<dynamic>.filled(N + 1, null);
|
||||
var firstSuccs = _newUint32Array(N + 2);
|
||||
var succs = _newUint32Array(E);
|
||||
var eid = 0;
|
||||
|
@ -1378,7 +1378,7 @@ class _SnapshotGraph implements SnapshotGraph {
|
|||
for (var i = 1; i <= N; i++) {
|
||||
label[i] = i;
|
||||
}
|
||||
final buckets = new List(N + 1);
|
||||
final buckets = List<dynamic>.filled(N + 1, null);
|
||||
final child = _newUint32Array(N + 1);
|
||||
final size = _newUint32Array(N + 1);
|
||||
for (var i = 1; i <= N; i++) {
|
||||
|
@ -1405,7 +1405,7 @@ class _SnapshotGraph implements SnapshotGraph {
|
|||
// w.semi.bucket.add(w);
|
||||
var tmp = vertex[semi[w]];
|
||||
if (buckets[tmp] == null) {
|
||||
buckets[tmp] = new List();
|
||||
buckets[tmp] = [];
|
||||
}
|
||||
buckets[tmp].add(w);
|
||||
|
||||
|
|
|
@ -4418,7 +4418,7 @@ class Code extends HeapObject implements M.Code {
|
|||
void _processDisassembly(List disassembly) {
|
||||
assert(disassembly != null);
|
||||
instructions.clear();
|
||||
instructionsByAddressOffset = new List(endAddress - startAddress);
|
||||
instructionsByAddressOffset = List.filled(endAddress - startAddress, null);
|
||||
|
||||
assert((disassembly.length % 4) == 0);
|
||||
for (var i = 0; i < disassembly.length; i += 4) {
|
||||
|
|
|
@ -19,7 +19,7 @@ const int LINE_C = 28;
|
|||
class NotGeneric {}
|
||||
|
||||
testeeMain() {
|
||||
var x = new List(1);
|
||||
var x = new List<dynamic>.filled(1, null);
|
||||
var y = 7;
|
||||
debugger();
|
||||
print("Statement");
|
||||
|
|
|
@ -26,7 +26,7 @@ var tests = <IsolateTest>[
|
|||
expect(errorResult.toString(), contains('can be evaluated only'));
|
||||
}
|
||||
|
||||
Instance someArray = await root.evaluate("new List(2)");
|
||||
Instance someArray = await root.evaluate("List.filled(2, null)");
|
||||
print(someArray);
|
||||
expect(someArray is Instance, isTrue);
|
||||
Class classArray = await someArray.clazz.load();
|
||||
|
|
|
@ -27,7 +27,7 @@ Expando<_TestClass> expando = Expando<_TestClass>();
|
|||
@pragma("vm:entry-point") // Prevent obfuscation
|
||||
var globalObject = new _TestClass();
|
||||
@pragma("vm:entry-point") // Prevent obfuscation
|
||||
var globalList = new List(100);
|
||||
var globalList = new List<dynamic>.filled(100, null);
|
||||
@pragma("vm:entry-point") // Prevent obfuscation
|
||||
var globalMap1 = new Map();
|
||||
@pragma("vm:entry-point") // Prevent obfuscation
|
||||
|
|
|
@ -24,7 +24,7 @@ void script() {
|
|||
n = new Node();
|
||||
e = new Edge();
|
||||
n.edge = e;
|
||||
array = new List(2);
|
||||
array = new List<dynamic>.filled(2, null);
|
||||
array[0] = n;
|
||||
array[1] = e;
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ void script() {
|
|||
r.right = b;
|
||||
a.left = b;
|
||||
|
||||
lst = new List(2);
|
||||
lst = new List<dynamic>.filled(2, null);
|
||||
lst[0] = lst; // Self-loop.
|
||||
// Larger than any other fixed-size list in a fresh heap.
|
||||
lst[1] = new List(1234569);
|
||||
lst[1] = new List<dynamic>.filled(1234569, null);
|
||||
}
|
||||
|
||||
var tests = <IsolateTest>[
|
||||
|
|
|
@ -26,11 +26,11 @@ buildGraph() {
|
|||
p2 = new Pair();
|
||||
|
||||
// Adds to both reachable and retained size.
|
||||
p1.x = new List();
|
||||
p2.x = new List();
|
||||
p1.x = [];
|
||||
p2.x = [];
|
||||
|
||||
// Adds to reachable size only.
|
||||
p1.y = p2.y = new List();
|
||||
p1.y = p2.y = [];
|
||||
}
|
||||
|
||||
Future<int> getReachableSize(ServiceObject obj) async {
|
||||
|
|
|
@ -138,7 +138,7 @@ class Node {
|
|||
mixedType = "2";
|
||||
mixedType = false;
|
||||
|
||||
array = new List(3);
|
||||
array = List.filled(3, null);
|
||||
array[0] = 1;
|
||||
array[1] = 2;
|
||||
array[2] = 3;
|
||||
|
@ -156,7 +156,7 @@ class Node {
|
|||
float64 = 3.14;
|
||||
float64x2 = new Float64x2(0.0, 3.14);
|
||||
gauge = new Gauge("GaugeName", "Gauge description", 0.0, 100.0);
|
||||
growableList = new List();
|
||||
growableList = [];
|
||||
int32x4 = new Int32x4(0, 1, 10, 11);
|
||||
map = {
|
||||
"x-key": "x-value",
|
||||
|
|
|
@ -75,7 +75,7 @@ testSimpleReadWriteClose() async {
|
|||
int bytesRead = 0;
|
||||
int bytesWritten = 0;
|
||||
bool closedEventReceived = false;
|
||||
List<int> data = new List<int>(messageSize);
|
||||
List<int> data = new List<int>.filled(messageSize, 0);
|
||||
bool doneReading = false;
|
||||
|
||||
client.writeEventsEnabled = false;
|
||||
|
@ -163,7 +163,7 @@ testSimpleReadWriteClose() async {
|
|||
socket.writeEventsEnabled = true;
|
||||
} else {
|
||||
print("server WRITE event: done writing");
|
||||
data = new List<int>(messageSize);
|
||||
data = new List<int>.filled(messageSize, 0);
|
||||
}
|
||||
break;
|
||||
case RawSocketEvent.readClosed:
|
||||
|
@ -217,7 +217,7 @@ testSimpleReadWriteShutdown({bool dropReads}) async {
|
|||
int bytesRead = 0;
|
||||
int bytesWritten = 0;
|
||||
bool closedEventReceived = false;
|
||||
List<int> data = new List<int>(messageSize);
|
||||
List<int> data = new List<int>.filled(messageSize, 0);
|
||||
bool doneReading = false;
|
||||
|
||||
client.writeEventsEnabled = false;
|
||||
|
@ -315,7 +315,7 @@ testSimpleReadWriteShutdown({bool dropReads}) async {
|
|||
socket.writeEventsEnabled = true;
|
||||
} else {
|
||||
print("server WRITE event: done writing");
|
||||
data = new List<int>(messageSize);
|
||||
data = new List<int>.filled(messageSize, 0);
|
||||
}
|
||||
break;
|
||||
case RawSocketEvent.readClosed:
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
void foo() {
|
||||
try {
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
List(10).toList(growable: true);
|
||||
List.filled(10, null).toList(growable: true);
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class Dog {}
|
|||
// Prevent obfuscation.
|
||||
@pragma('vm:entry-point')
|
||||
List<T> decodeFrom<T>(String s) {
|
||||
return List();
|
||||
return [];
|
||||
}
|
||||
|
||||
// Prevent obfuscation.
|
||||
|
|
|
@ -116,7 +116,6 @@ namespace dart {
|
|||
V(RegExp_getGroupNameMap, 1) \
|
||||
V(RegExp_ExecuteMatch, 3) \
|
||||
V(RegExp_ExecuteMatchSticky, 3) \
|
||||
V(List_new, 2) \
|
||||
V(List_allocate, 2) \
|
||||
V(List_getIndexed, 2) \
|
||||
V(List_setIndexed, 3) \
|
||||
|
|
|
@ -4177,29 +4177,6 @@ bool FlowGraphInliner::TryInlineRecognizedMethod(
|
|||
return true;
|
||||
}
|
||||
|
||||
case MethodRecognizer::kListFactory: {
|
||||
// We only want to inline new List(n) which decreases code size and
|
||||
// improves performance. We don't want to inline new List().
|
||||
if (call->ArgumentCount() != 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto type = new (Z) Value(call->ArgumentAt(0));
|
||||
const auto num_elements = new (Z) Value(call->ArgumentAt(1));
|
||||
*entry = new (Z)
|
||||
FunctionEntryInstr(graph_entry, flow_graph->allocate_block_id(),
|
||||
call->GetBlock()->try_index(), DeoptId::kNone);
|
||||
(*entry)->InheritDeoptTarget(Z, call);
|
||||
*last = new (Z) CreateArrayInstr(call->source(), type, num_elements,
|
||||
call->deopt_id());
|
||||
flow_graph->AppendTo(
|
||||
*entry, *last,
|
||||
call->deopt_id() != DeoptId::kNone ? call->env() : NULL,
|
||||
FlowGraph::kValue);
|
||||
*result = (*last)->AsDefinition();
|
||||
return true;
|
||||
}
|
||||
|
||||
case MethodRecognizer::kObjectArrayAllocate: {
|
||||
Value* num_elements = new (Z) Value(call->ArgumentAt(1));
|
||||
intptr_t length = 0;
|
||||
|
|
|
@ -1013,7 +1013,6 @@ bool FlowGraphBuilder::IsRecognizedMethodForFlowGraph(
|
|||
case MethodRecognizer::kClassIDgetID:
|
||||
case MethodRecognizer::kGrowableArrayAllocateWithData:
|
||||
case MethodRecognizer::kGrowableArrayCapacity:
|
||||
case MethodRecognizer::kListFactory:
|
||||
case MethodRecognizer::kObjectArrayAllocate:
|
||||
case MethodRecognizer::kCopyRangeFromUint8ListToOneByteString:
|
||||
case MethodRecognizer::kImmutableLinkedHashBase_setIndexStoreRelease:
|
||||
|
@ -1172,69 +1171,6 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfRecognizedMethod(
|
|||
body += LoadNativeField(Slot::GrowableObjectArray_data());
|
||||
body += LoadNativeField(Slot::Array_length());
|
||||
break;
|
||||
case MethodRecognizer::kListFactory: {
|
||||
ASSERT(function.IsFactory() && (function.NumParameters() == 2) &&
|
||||
function.HasOptionalParameters());
|
||||
// factory List<E>([int length]) {
|
||||
// return (:arg_desc.positional_count == 2) ? new _List<E>(length)
|
||||
// : new _GrowableList<E>(0);
|
||||
// }
|
||||
const Library& core_lib = Library::Handle(Z, Library::CoreLibrary());
|
||||
|
||||
TargetEntryInstr* allocate_non_growable;
|
||||
TargetEntryInstr* allocate_growable;
|
||||
|
||||
body += LoadArgDescriptor();
|
||||
body += LoadNativeField(Slot::ArgumentsDescriptor_positional_count());
|
||||
body += IntConstant(2);
|
||||
body += BranchIfStrictEqual(&allocate_non_growable, &allocate_growable);
|
||||
|
||||
JoinEntryInstr* join = BuildJoinEntry();
|
||||
|
||||
{
|
||||
const Class& cls = Class::Handle(
|
||||
Z, core_lib.LookupClass(
|
||||
Library::PrivateCoreLibName(Symbols::_List())));
|
||||
ASSERT(!cls.IsNull());
|
||||
const Function& func = Function::ZoneHandle(
|
||||
Z, cls.LookupFactoryAllowPrivate(Symbols::_ListFactory()));
|
||||
ASSERT(!func.IsNull());
|
||||
|
||||
Fragment allocate(allocate_non_growable);
|
||||
allocate += LoadLocal(parsed_function_->RawParameterVariable(0));
|
||||
allocate += LoadLocal(parsed_function_->RawParameterVariable(1));
|
||||
allocate +=
|
||||
StaticCall(TokenPosition::kNoSource, func, 2, ICData::kStatic);
|
||||
allocate += StoreLocal(TokenPosition::kNoSource,
|
||||
parsed_function_->expression_temp_var());
|
||||
allocate += Drop();
|
||||
allocate += Goto(join);
|
||||
}
|
||||
|
||||
{
|
||||
const Class& cls = Class::Handle(
|
||||
Z, core_lib.LookupClass(
|
||||
Library::PrivateCoreLibName(Symbols::_GrowableList())));
|
||||
ASSERT(!cls.IsNull());
|
||||
const Function& func = Function::ZoneHandle(
|
||||
Z, cls.LookupFactoryAllowPrivate(Symbols::_GrowableListFactory()));
|
||||
ASSERT(!func.IsNull());
|
||||
|
||||
Fragment allocate(allocate_growable);
|
||||
allocate += LoadLocal(parsed_function_->RawParameterVariable(0));
|
||||
allocate += IntConstant(0);
|
||||
allocate +=
|
||||
StaticCall(TokenPosition::kNoSource, func, 2, ICData::kStatic);
|
||||
allocate += StoreLocal(TokenPosition::kNoSource,
|
||||
parsed_function_->expression_temp_var());
|
||||
allocate += Drop();
|
||||
allocate += Goto(join);
|
||||
}
|
||||
|
||||
body = Fragment(body.entry, join);
|
||||
body += LoadLocal(parsed_function_->expression_temp_var());
|
||||
break;
|
||||
}
|
||||
case MethodRecognizer::kObjectArrayAllocate:
|
||||
ASSERT(function.IsFactory() && (function.NumParameters() == 2));
|
||||
body += LoadLocal(parsed_function_->RawParameterVariable(0));
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace dart {
|
|||
V(::, identical, ObjectIdentical, 0x04168315) \
|
||||
V(ClassID, getID, ClassIDgetID, 0xdc8b888a) \
|
||||
V(Object, Object., ObjectConstructor, 0xab6d6cfa) \
|
||||
V(List, ., ListFactory, 0x1892cc51) \
|
||||
V(_List, ., ObjectArrayAllocate, 0x4c9d39e2) \
|
||||
V(_List, []=, ObjectArraySetIndexed, 0x050cd2ba) \
|
||||
V(_GrowableList, ._withData, GrowableArrayAllocateWithData, 0x1947d8a1) \
|
||||
|
|
|
@ -6589,24 +6589,6 @@ TEST_CASE(DartAPI_InvokeClosure_Issue44205) {
|
|||
EXPECT_ERROR(result, "String' is not a subtype of type 'int' of 'j'");
|
||||
}
|
||||
|
||||
TEST_CASE(DartAPI_New_Issue2971) {
|
||||
// Issue 2971: We were unable to use Dart_New to construct an
|
||||
// instance of List, due to problems implementing interface
|
||||
// factories.
|
||||
Dart_Handle core_lib = Dart_LookupLibrary(NewString("dart:core"));
|
||||
EXPECT_VALID(core_lib);
|
||||
Dart_Handle list_type =
|
||||
Dart_GetNonNullableType(core_lib, NewString("List"), 0, NULL);
|
||||
EXPECT_VALID(list_type);
|
||||
|
||||
const int kNumArgs = 1;
|
||||
Dart_Handle args[kNumArgs];
|
||||
args[0] = Dart_NewInteger(1);
|
||||
Dart_Handle list_obj = Dart_New(list_type, Dart_Null(), kNumArgs, args);
|
||||
EXPECT_VALID(list_obj);
|
||||
EXPECT(Dart_IsList(list_obj));
|
||||
}
|
||||
|
||||
TEST_CASE(DartAPI_NewListOf) {
|
||||
const char* kScriptChars =
|
||||
"String expectListOfString(List<String> o) => '${o.first}';\n"
|
||||
|
|
|
@ -12,11 +12,6 @@ class List<E> {
|
|||
return growable ? <E>[] : _List<E>(0);
|
||||
}
|
||||
|
||||
@patch
|
||||
@pragma("vm:recognized", "other")
|
||||
@pragma("vm:external-name", "List_new")
|
||||
external factory List([int? length]);
|
||||
|
||||
@patch
|
||||
factory List.filled(int length, E fill, {bool growable = false}) {
|
||||
// All error handling on the length parameter is done at the implementation
|
||||
|
|
|
@ -113,43 +113,6 @@ part of dart.core;
|
|||
/// directly or through iterating an [Iterable] that is backed by the list, will
|
||||
/// break the iteration.
|
||||
abstract class List<E> implements EfficientLengthIterable<E> {
|
||||
/// Creates a list of the given length.
|
||||
///
|
||||
/// **NOTE**: This constructor cannot be used in null-safe code.
|
||||
/// Use [List.filled] to create a non-empty list.
|
||||
/// This requires a fill value to initialize the list elements with.
|
||||
/// To create an empty list, use `[]` for a growable list or
|
||||
/// `List.empty` for a fixed length list (or where growability is determined
|
||||
/// at run-time).
|
||||
///
|
||||
/// The created list is fixed-length if [length] is provided.
|
||||
/// ```dart
|
||||
/// var fixedLengthList = List(3);
|
||||
/// fixedLengthList.length; // 3
|
||||
/// fixedLengthList.length = 1; // Error
|
||||
/// ```
|
||||
/// The list has length 0 and is growable if [length] is omitted.
|
||||
/// ```dart
|
||||
/// var growableList = List();
|
||||
/// growableList.length; // 0;
|
||||
/// growableList.length = 3;
|
||||
/// ```
|
||||
/// To create a growable list with a given length, for a nullable element type,
|
||||
/// just assign the length right after creation:
|
||||
/// ```dart
|
||||
/// List<SomeNullableType> growableList = []..length = 500;
|
||||
/// ```
|
||||
/// For a non-nullable element type, an alternative is the following:
|
||||
/// ```dart
|
||||
/// List<int> growableList = List<int>.filled(500, 0, growable: true);
|
||||
/// ```
|
||||
/// The [length] must not be negative or null, if it is provided.
|
||||
///
|
||||
/// If the element type is not nullable, [length] must not be greater than
|
||||
/// zero.
|
||||
@Deprecated("Use a list literal, [], or the List.filled constructor instead")
|
||||
external factory List([int? length]);
|
||||
|
||||
/// Creates a list of the given length with [fill] at each position.
|
||||
///
|
||||
/// The [length] must be a non-negative integer.
|
||||
|
|
|
@ -72,7 +72,7 @@ main() {
|
|||
testCollection(new LinkedHashSet(), N);
|
||||
testCollection(new ListQueue(), N);
|
||||
testCollection(new DoubleLinkedQueue(), N);
|
||||
testList(new List()..length = N, N);
|
||||
testList(new List(N), N);
|
||||
testList([]..length = N, N);
|
||||
testList(new List.filled(N, null), N);
|
||||
testString(N);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ main() {
|
|||
new CollectionTest(TEST_ELEMENTS);
|
||||
|
||||
// Fixed size list.
|
||||
var fixedList = new List<int>(TEST_ELEMENTS.length);
|
||||
var fixedList = new List<int>.filled(TEST_ELEMENTS.length, null);
|
||||
for (int i = 0; i < TEST_ELEMENTS.length; i++) {
|
||||
fixedList[i] = TEST_ELEMENTS[i];
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class ExpandoTest {
|
|||
visits = new Expando<int>('visits');
|
||||
var legal = [
|
||||
new Object(),
|
||||
new List(),
|
||||
[],
|
||||
[1, 2, 3],
|
||||
const [1, 2, 3],
|
||||
new Map(),
|
||||
|
|
|
@ -82,7 +82,7 @@ class ForInTest {
|
|||
|
||||
static void testClosure() {
|
||||
Set<int> set = getSmallSet();
|
||||
List<Function> closures = new List(set.length);
|
||||
List<Function> closures = new List.filled(set.length, null);
|
||||
int index = 0;
|
||||
for (var i in set) {
|
||||
closures[index++] = () => i;
|
||||
|
|
|
@ -85,21 +85,21 @@ void testConstructor() {
|
|||
Expect.throws(fn, null, name);
|
||||
}
|
||||
|
||||
testFixedLength(new List<int>(0));
|
||||
testFixedLength(new List<int>(5));
|
||||
testFixedLength(new List<int>.filled(0, null));
|
||||
testFixedLength(new List<int>.filled(5, null));
|
||||
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");
|
||||
Expect.throwsArgumentError(() => new List<int>.filled(null, null), "null");
|
||||
testThrowsOrTypeError(
|
||||
() => new List([] as Object), // Cast to avoid warning.
|
||||
() => new List.filled([] as Object, null), // Cast to avoid warning.
|
||||
'list');
|
||||
testThrowsOrTypeError(() => new List([42] as Object), "list2");
|
||||
testThrowsOrTypeError(() => new List.filled([42] as Object, null), "list2");
|
||||
}
|
||||
|
||||
void testConcurrentModification() {
|
||||
|
|
|
@ -17,8 +17,8 @@ test(list, notInList) {
|
|||
Expect.isFalse(list.contains(notInList), "!$list.contains($notInList)");
|
||||
}
|
||||
|
||||
List fixedList = new List(list.length);
|
||||
List growList = new List();
|
||||
List fixedList = new List.filled(list.length, null);
|
||||
List growList = [];
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
fixedList[i] = list[i];
|
||||
growList.add(list[i]);
|
||||
|
|
|
@ -27,7 +27,7 @@ main() {
|
|||
for (dynamic iterable in [
|
||||
const [1, 2, 3],
|
||||
[1, 2, 3],
|
||||
new List(3)
|
||||
new List<int>.filled(3, null)
|
||||
..[0] = 1
|
||||
..[1] = 2
|
||||
..[2] = 3,
|
||||
|
@ -88,7 +88,7 @@ main() {
|
|||
for (var iterable in [
|
||||
const [],
|
||||
[],
|
||||
new List(0),
|
||||
new List.filled(0, null),
|
||||
{}.keys,
|
||||
{}.values,
|
||||
new Iterable.generate(0, (x) => x + 1),
|
||||
|
@ -118,7 +118,7 @@ main() {
|
|||
for (dynamic iterable in [
|
||||
const [1],
|
||||
[1],
|
||||
new List(1)..[0] = 1,
|
||||
new List<int>.filled(1, null)..[0] = 1,
|
||||
{1: 1}.keys,
|
||||
{1: 1}.values,
|
||||
new Iterable.generate(1, (x) => x + 1),
|
||||
|
|
|
@ -63,7 +63,7 @@ testCollections() {
|
|||
}
|
||||
|
||||
testArray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
||||
var fixedArray = new List<int>(10);
|
||||
var fixedArray = new List<int>.filled(10, null);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
fixedArray[i] = i;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ main() {
|
|||
for (dynamic iterable in [
|
||||
const [1, 2, 3],
|
||||
[1, 2, 3],
|
||||
new List(3)
|
||||
new List<int>.filled(3, null)
|
||||
..[0] = 1
|
||||
..[1] = 2
|
||||
..[2] = 3,
|
||||
|
@ -90,7 +90,7 @@ main() {
|
|||
for (var iterable in [
|
||||
const [],
|
||||
[],
|
||||
new List(0),
|
||||
new List.filled(0, null),
|
||||
{}.keys,
|
||||
{}.values,
|
||||
new Iterable.generate(0, (x) => x + 1),
|
||||
|
@ -121,7 +121,7 @@ main() {
|
|||
for (dynamic iterable in [
|
||||
const [1],
|
||||
[1],
|
||||
new List(1)..[0] = 1,
|
||||
new List<int>.filled(1, null)..[0] = 1,
|
||||
{1: 1}.keys,
|
||||
{1: 1}.values,
|
||||
new Iterable.generate(1, (x) => x + 1),
|
||||
|
|
|
@ -15,14 +15,14 @@ import 'dart:typed_data';
|
|||
main() {
|
||||
// Empty lists.
|
||||
testList(<int>[]);
|
||||
testList(new List<int>(0));
|
||||
testList(new List<int>());
|
||||
testList(new List<int>.filled(0, null));
|
||||
testList(<int>[]);
|
||||
testList(const <int>[]);
|
||||
testList(new List<int>.generate(0, (x) => x + 1));
|
||||
// Singleton lists.
|
||||
testList(<int>[1]);
|
||||
testList(new List<int>(1)..[0] = 1);
|
||||
testList(new List<int>()..add(1));
|
||||
testList(new List<int>.filled(1, null)..[0] = 1);
|
||||
testList(<int>[]..add(1));
|
||||
testList(const <int>[1]);
|
||||
testList(new List<int>.generate(1, (x) => x + 1));
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ class LinkedHashMapTest {
|
|||
map["d"] = 4;
|
||||
map["e"] = 5;
|
||||
|
||||
List<String> keys = new List<String>(5);
|
||||
List<int> values = new List<int>(5);
|
||||
List<String> keys = new List<String>.filled(5, null);
|
||||
List<int> values = new List<int>.filled(5, null);
|
||||
|
||||
int index;
|
||||
|
||||
|
|
|
@ -87,11 +87,11 @@ void testAsMap(List list) {
|
|||
main() {
|
||||
testConstAsMap(const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
||||
testAsMap([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
||||
List list = new List(10);
|
||||
List list = new List.filled(10, null);
|
||||
for (int i = 0; i < 10; i++) list[i] = i + 1;
|
||||
testFixedAsMap(list);
|
||||
|
||||
testConstAsMap(const []);
|
||||
testAsMap([]);
|
||||
testFixedAsMap(new List(0));
|
||||
testFixedAsMap(new List.filled(0, null));
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ import "package:expect/expect.dart";
|
|||
|
||||
void main() {
|
||||
// Growable lists. Initial length 0.
|
||||
testConcurrentModification(new List());
|
||||
testConcurrentModification(new List<int>().toList());
|
||||
testConcurrentModification(new List<int>(0).toList());
|
||||
testConcurrentModification([]);
|
||||
testConcurrentModification(<int>[].toList());
|
||||
testConcurrentModification(new List<int>.filled(0, null).toList());
|
||||
testConcurrentModification(new List.filled(0, null, growable: true));
|
||||
testConcurrentModification([]);
|
||||
testConcurrentModification(new List.from(const []));
|
||||
|
|
|
@ -26,8 +26,8 @@ main() {
|
|||
|
||||
var iterables = <dynamic>[
|
||||
<A>[new A()],
|
||||
new List<A>(1)..[0] = new A(),
|
||||
new List<A>()..add(new A()),
|
||||
new List<A>.filled(1, null)..[0] = new A(),
|
||||
<A>[]..add(new A()),
|
||||
const <A>[const A()],
|
||||
new Set()..add(new A()),
|
||||
(new Map()..[new A()] = 0).keys,
|
||||
|
|
|
@ -87,7 +87,7 @@ void main() {
|
|||
Expect.listEquals([1, 2, 12, 256 - 13], listu8);
|
||||
|
||||
var clist = const <int>[1, 2, 3, 4];
|
||||
var flist = new List<int>(4)..setAll(0, [10, 11, 12, 13]);
|
||||
var flist = new List<int>.filled(4, null)..setAll(0, [10, 11, 12, 13]);
|
||||
List.copyRange(flist, 1, clist, 1, 3);
|
||||
Expect.listEquals([10, 2, 3, 13], flist);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import "package:expect/expect.dart";
|
|||
main() {
|
||||
var a;
|
||||
|
||||
a = new List(42);
|
||||
a = new List<dynamic>.filled(42, null);
|
||||
Expect.equals(42, a.length);
|
||||
Expect.throwsUnsupportedError(() => a.add(499));
|
||||
Expect.equals(42, a.length);
|
||||
|
|
|
@ -37,10 +37,10 @@ void testWithModification(List list) {
|
|||
}
|
||||
|
||||
main() {
|
||||
List fixedLengthList = new List(10);
|
||||
List fixedLengthList = new List.filled(10, null);
|
||||
for (int i = 0; i < 10; i++) fixedLengthList[i] = i + 1;
|
||||
|
||||
List growableList = new List();
|
||||
List growableList = [];
|
||||
growableList.length = 10;
|
||||
for (int i = 0; i < 10; i++) growableList[i] = i + 1;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
main() {
|
||||
var a;
|
||||
a = new List();
|
||||
a = [];
|
||||
a.add(499);
|
||||
Expect.equals(1, a.length);
|
||||
Expect.equals(499, a[0]);
|
||||
|
@ -16,7 +16,7 @@ main() {
|
|||
Expect.equals(0, a.length);
|
||||
Expect.throwsRangeError(() => a[0]);
|
||||
|
||||
a = new List(42).toList();
|
||||
a = new List<dynamic>.filled(42, null).toList();
|
||||
Expect.equals(42, a.length);
|
||||
a.add(499);
|
||||
Expect.equals(43, a.length);
|
||||
|
@ -26,7 +26,7 @@ main() {
|
|||
Expect.equals(0, a.length);
|
||||
Expect.throwsRangeError(() => a[0]);
|
||||
|
||||
a = new List<int>(42).toList();
|
||||
a = new List<int>.filled(42, null).toList();
|
||||
Expect.equals(42, a.length);
|
||||
a.add(499);
|
||||
Expect.equals(43, a.length);
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
test(new List<int>(5));
|
||||
var l = new List<int>();
|
||||
test(new List<int>.filled(5, null));
|
||||
var l = <int>[];
|
||||
l.length = 5;
|
||||
test(l);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ void main() {
|
|||
testModifiableList(new MyList([0, 1, 2, 3, 4]));
|
||||
|
||||
// Fixed size list.
|
||||
var l2 = new List(5);
|
||||
var l2 = new List<dynamic>.filled(5, null);
|
||||
for (var i = 0; i < 5; i++) l2[i] = i;
|
||||
Expect.throwsUnsupportedError(() => l2.insert(2, 5), "fixed-length");
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@ class ListIteratorsTest {
|
|||
static testMain() {
|
||||
checkListIterator([]);
|
||||
checkListIterator([1, 2]);
|
||||
checkListIterator(new List(0));
|
||||
checkListIterator(new List(10));
|
||||
checkListIterator(new List());
|
||||
List g = new List();
|
||||
checkListIterator(new List.filled(0, null));
|
||||
checkListIterator(new List.filled(10, null));
|
||||
checkListIterator([]);
|
||||
List g = [];
|
||||
g.addAll([1, 2, 3]);
|
||||
checkListIterator(g);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ void testOperations() {
|
|||
|
||||
void testList(List list) {
|
||||
var throws = const ThrowMarker();
|
||||
var mappedList = new List<int>(list.length);
|
||||
var mappedList = new List<int>.filled(list.length, null);
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
mappedList[i] = rev(list[i]);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ void main() {
|
|||
testModifiableList(new MyList([0, 1, 2, 3, 4]));
|
||||
|
||||
// Fixed size list.
|
||||
var l2 = new List(5);
|
||||
var l2 = new List<dynamic>.filled(5, null);
|
||||
for (var i = 0; i < 5; i++) l2[i] = i;
|
||||
Expect.throwsUnsupportedError(() => l2.removeAt(2), "fixed-length");
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void testOperations() {
|
|||
}
|
||||
|
||||
void testOp(operation(Iterable<int> reversedList), name) {
|
||||
var reversedList = new List<int>(list.length);
|
||||
var reversedList = new List<int>.filled(list.length, null);
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
reversedList[i] = list[list.length - 1 - i];
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ void testNegativeIndices() {
|
|||
}
|
||||
|
||||
void testNonExtendableList() {
|
||||
var list = new List<int>(6);
|
||||
var list = new List<int>.filled(6, null);
|
||||
Expect.listEquals([null, null, null, null, null, null], list);
|
||||
list.setRange(0, 3, [1, 2, 3, 4]);
|
||||
list.setRange(3, 6, [1, 2, 3, 4]);
|
||||
|
|
|
@ -24,17 +24,17 @@ void main() {
|
|||
testTypedList(new Int32List(4).toList(growable: false));
|
||||
|
||||
// Fixed length lists, length 4.
|
||||
testFixedLengthList(<T>() => new List(4));
|
||||
testFixedLengthList(<T>() => new List<T>(4).toList(growable: false));
|
||||
testFixedLengthList(<T>() => (new List<T>()..length = 4).toList(growable: false));
|
||||
testFixedLengthList(<T>() => new List.filled(4, null));
|
||||
testFixedLengthList(<T>() => new List<T>.filled(4, null).toList(growable: false));
|
||||
testFixedLengthList(<T>() => (<T>[]..length = 4).toList(growable: false));
|
||||
// ListBase implementation of List.
|
||||
testFixedLengthList(<T>() => new MyFixedList(new List(4)));
|
||||
testFixedLengthList(<T>() => new MyFixedList<T>(new List(4)).toList(growable: false));
|
||||
testFixedLengthList(<T>() => new MyFixedList(new List.filled(4, null)));
|
||||
testFixedLengthList(<T>() => new MyFixedList<T>(new List.filled(4, null)).toList(growable: false));
|
||||
|
||||
// Growable lists. Initial length 0.
|
||||
testGrowableList(<T>() => new List());
|
||||
testGrowableList(<T>() => new List<T>().toList());
|
||||
testGrowableList(<T>() => new List<T>(0).toList());
|
||||
testGrowableList(<T>() => []);
|
||||
testGrowableList(<T>() => <T>[].toList());
|
||||
testGrowableList(<T>() => new List<T>.filled(0, null).toList());
|
||||
testGrowableList(<T>() => new List.filled(0, null, growable: true));
|
||||
testGrowableList(<T>() => []);
|
||||
testGrowableList(<T>() => new List.from(const []));
|
||||
|
@ -120,7 +120,7 @@ void testErrors() {
|
|||
|
||||
// Empty lists.
|
||||
testRangeErrors([], "list");
|
||||
testRangeErrors(new List(0), "fixed-list");
|
||||
testRangeErrors(new List.filled(0, null), "fixed-list");
|
||||
testRangeErrors(const [], "const-list");
|
||||
testRangeErrors(new List.unmodifiable([]), "unmodifiable");
|
||||
testRangeErrors(new Uint8List(0), "typed-list");
|
||||
|
@ -128,7 +128,7 @@ void testErrors() {
|
|||
testRangeErrors([1, 2, 3].sublist(1, 1), "sub-list");
|
||||
// Non-empty lists.
|
||||
testRangeErrors([1, 2, 3], "list");
|
||||
testRangeErrors(new List(3), "fixed-list");
|
||||
testRangeErrors(new List.filled(3, null), "fixed-list");
|
||||
testRangeErrors(const [1, 2, 3], "const-list");
|
||||
testRangeErrors(new List.unmodifiable([1, 2, 3]), "unmodifiable");
|
||||
testRangeErrors(new Uint8List(3), "typed-list");
|
||||
|
@ -570,15 +570,15 @@ class MyFixedList<E> extends ListBase<E> {
|
|||
|
||||
void testListConstructor() {
|
||||
// Is fixed-length.
|
||||
Expect.throws(() => new List(0).add(4));
|
||||
Expect.throws(() => new List(-2)); // Not negative. //# 01: ok
|
||||
Expect.throws(() => new List<dynamic>.filled(0, null).add(4));
|
||||
Expect.throws(() => new List<dynamic>.filled(-2, null)); // Not negative. //# 01: ok
|
||||
// Not null.
|
||||
Expect.throws(() => new List(null));
|
||||
Expect.listEquals([4], new List()..add(4));
|
||||
Expect.throws(() => new List<dynamic>.filled(null, null));
|
||||
Expect.listEquals([4], []..add(4));
|
||||
// Is fixed-length.
|
||||
Expect.throws(() => new List.filled(0, 42).add(4));
|
||||
Expect.throws(() => new List<dynamic>.filled(0, 42).add(4));
|
||||
// Not negative.
|
||||
Expect.throws(() => new List.filled(-2, 42));
|
||||
Expect.throws(() => new List<dynamic>.filled(-2, 42));
|
||||
// Not null.
|
||||
Expect.throws(() => new List.filled(null, 42));
|
||||
Expect.throws(() => new List<dynamic>.filled(null, 42));
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ main() {
|
|||
List list = [1, 2];
|
||||
list.add(list);
|
||||
|
||||
List list2 = new List(4);
|
||||
List list2 = new List.filled(4, null);
|
||||
list2[0] = 1;
|
||||
list2[1] = 2;
|
||||
list2[2] = list2;
|
||||
|
|
|
@ -230,13 +230,13 @@ List<int> createConstList(int n) {
|
|||
}
|
||||
|
||||
List<int> createFixedList(int n) {
|
||||
var result = new List<int>(n);
|
||||
var result = new List<int>.filled(n, null);
|
||||
for (int i = 0; i < n; i++) result[i] = n;
|
||||
return result;
|
||||
}
|
||||
|
||||
List<int> createGrowableList(int n) {
|
||||
var result = new List<int>()..length = n;
|
||||
var result = <int>[]..length = n;
|
||||
for (int i = 0; i < n; i++) result[i] = n;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -24,11 +24,11 @@ void testRead() {
|
|||
testListRead(list, -1);
|
||||
testListRead(list, 1);
|
||||
|
||||
list = new List(1);
|
||||
list = new List.filled(1, null);
|
||||
testListRead(list, -1);
|
||||
testListRead(list, 1);
|
||||
|
||||
list = new List();
|
||||
list = [];
|
||||
testListRead(list, -1);
|
||||
testListRead(list, 0);
|
||||
testListRead(list, 1);
|
||||
|
@ -43,11 +43,11 @@ void testWrite() {
|
|||
testListWrite(list, -1);
|
||||
testListWrite(list, 1);
|
||||
|
||||
list = new List(1);
|
||||
list = new List.filled(1, null);
|
||||
testListWrite(list, -1);
|
||||
testListWrite(list, 1);
|
||||
|
||||
list = new List();
|
||||
list = [];
|
||||
testListWrite(list, -1);
|
||||
testListWrite(list, 0);
|
||||
testListWrite(list, 1);
|
||||
|
|
|
@ -123,9 +123,9 @@ void main() {
|
|||
re_string = re_string + "1";
|
||||
// re_string = "(((...((a))...)))1"
|
||||
|
||||
var regexps = new List();
|
||||
var last_match_expectations = new List();
|
||||
var first_capture_expectations = new List();
|
||||
var regexps = [];
|
||||
var last_match_expectations = [];
|
||||
var first_capture_expectations = [];
|
||||
|
||||
// Atomic regexp.
|
||||
regexps.add(new RegExp(r"a1"));
|
||||
|
@ -158,7 +158,7 @@ void main() {
|
|||
var subject = "";
|
||||
var test_1_expectation = "";
|
||||
var test_2_expectation = "";
|
||||
var test_3_expectation = (m == 0) ? null : new List();
|
||||
var test_3_expectation = (m == 0) ? null : [];
|
||||
for (var i = 0; i < m; i++) {
|
||||
subject += "a11";
|
||||
test_1_expectation += "x1";
|
||||
|
|
|
@ -179,7 +179,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;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class SortHelper {
|
|||
}
|
||||
|
||||
void testSortIntLists() {
|
||||
var a = new List<int>(40);
|
||||
var a = new List<int>.filled(40, null);
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
a[i] = i;
|
||||
|
@ -85,10 +85,10 @@ class SortHelper {
|
|||
a[33] = 1;
|
||||
testSort(a);
|
||||
|
||||
var a2 = new List<int>(0);
|
||||
var a2 = new List<int>.filled(0, null);
|
||||
testSort(a2);
|
||||
|
||||
var a3 = new List<int>(1);
|
||||
var a3 = new List<int>.filled(1, null);
|
||||
a3[0] = 1;
|
||||
testSort(a3);
|
||||
|
||||
|
@ -126,7 +126,7 @@ class SortHelper {
|
|||
}
|
||||
|
||||
void testInsertionSort(int i1, int i2, int i3, int i4) {
|
||||
var a = new List<int>(4);
|
||||
var a = new List<int>.filled(4, null);
|
||||
a[0] = i1;
|
||||
a[1] = i2;
|
||||
a[2] = i3;
|
||||
|
@ -135,7 +135,7 @@ class SortHelper {
|
|||
}
|
||||
|
||||
void testSortDoubleLists() {
|
||||
var a = new List<double>(40);
|
||||
var a = new List<double>.filled(40, null);
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
a[i] = 1.0 * i + 0.5;
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ class StringBaseTest {
|
|||
|
||||
static testCreation() {
|
||||
String s = "Hello";
|
||||
List<int> a = new List(s.length);
|
||||
List<int> ga = new List();
|
||||
List<int> a = new List.filled(s.length, null);
|
||||
List<int> ga = [];
|
||||
bool exception_caught = false;
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
a[i] = s.codeUnitAt(i);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
import "package:expect/expect.dart";
|
||||
|
||||
void main() {
|
||||
Expect.equals("", new String.fromCharCodes(new List(0)));
|
||||
Expect.equals("", new String.fromCharCodes([]));
|
||||
Expect.equals("", new String.fromCharCodes(const []));
|
||||
Expect.equals("AB", new String.fromCharCodes([65, 66]));
|
||||
|
@ -15,7 +14,6 @@ void main() {
|
|||
Expect.equals("Ærø", new String.fromCharCodes(const [0xc6, 0x72, 0xf8]));
|
||||
Expect.equals("\u{1234}", new String.fromCharCodes([0x1234]));
|
||||
Expect.equals("\u{12345}*", new String.fromCharCodes([0x12345, 42]));
|
||||
Expect.equals("", new String.fromCharCodes(new List()));
|
||||
{
|
||||
var a = <int>[];
|
||||
a.add(65);
|
||||
|
@ -25,7 +23,7 @@ void main() {
|
|||
|
||||
// Long list (bug 6919).
|
||||
for (int len in [499, 500, 501, 999, 100000]) {
|
||||
List<int> list = new List(len);
|
||||
List<int> list = new List.filled(len, null);
|
||||
for (int i = 0; i < len; i++) {
|
||||
list[i] = 65 + (i % 26);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ main() {
|
|||
test("", iter(0));
|
||||
test("", <int>[]);
|
||||
test("", const <int>[]);
|
||||
test("", new List<int>(0));
|
||||
test("", new List<int>.filled(0, null));
|
||||
test("", new Uint8List(0));
|
||||
test("", new Uint16List(0));
|
||||
test("", new Uint32List(0));
|
||||
|
@ -34,7 +34,7 @@ main() {
|
|||
test("\x00", iter(1, 0));
|
||||
test("\x00", [0]);
|
||||
test("\x00", const [0]);
|
||||
test("\x00", new List<int>(1)..[0] = 0);
|
||||
test("\x00", new List<int>.filled(1, null)..[0] = 0);
|
||||
test("\x00", new Uint8List(1));
|
||||
test("\x00", new Uint16List(1));
|
||||
test("\x00", new Uint32List(1));
|
||||
|
@ -43,7 +43,7 @@ main() {
|
|||
test("\xff", iter(1, 255));
|
||||
test("\xFF", [255]);
|
||||
test("\xFF", const [255]);
|
||||
test("\xFF", new List<int>(1)..[0] = 255);
|
||||
test("\xFF", new List<int>.filled(1, null)..[0] = 255);
|
||||
test("\xFF", new Uint8List(1)..[0] = 255);
|
||||
test("\xFF", new Uint16List(1)..[0] = 255);
|
||||
test("\xFF", new Uint32List(1)..[0] = 255);
|
||||
|
@ -52,7 +52,7 @@ main() {
|
|||
test("\u0100", iter(1, 256));
|
||||
test("\u0100", [256]);
|
||||
test("\u0100", const [256]);
|
||||
test("\u0100", new List<int>(1)..[0] = 256);
|
||||
test("\u0100", new List<int>.filled(1, null)..[0] = 256);
|
||||
test("\u0100", new Uint16List(1)..[0] = 256);
|
||||
test("\u0100", new Uint32List(1)..[0] = 256);
|
||||
test("\u0100", "\u0100".codeUnits);
|
||||
|
@ -60,7 +60,7 @@ main() {
|
|||
test("\uffff", iter(1, 65535));
|
||||
test("\uffff", [65535]);
|
||||
test("\uffff", const [65535]);
|
||||
test("\uffff", new List<int>(1)..[0] = 65535);
|
||||
test("\uffff", new List<int>.filled(1, null)..[0] = 65535);
|
||||
test("\uffff", new Uint16List(1)..[0] = 65535);
|
||||
test("\uffff", new Uint32List(1)..[0] = 65535);
|
||||
test("\uffff", "\uffff".codeUnits);
|
||||
|
@ -68,14 +68,14 @@ main() {
|
|||
test("\u{10000}", iter(1, 65536));
|
||||
test("\u{10000}", [65536]);
|
||||
test("\u{10000}", const [65536]);
|
||||
test("\u{10000}", new List<int>(1)..[0] = 65536);
|
||||
test("\u{10000}", new List<int>.filled(1, null)..[0] = 65536);
|
||||
test("\u{10000}", new Uint32List(1)..[0] = 65536);
|
||||
test("\u{10000}", "\u{10000}".codeUnits);
|
||||
|
||||
test("\u{10FFFF}", iter(1, 0x10FFFF));
|
||||
test("\u{10FFFF}", [0x10FFFF]);
|
||||
test("\u{10FFFF}", const [0x10FFFF]);
|
||||
test("\u{10FFFF}", new List<int>(1)..[0] = 0x10FFFF);
|
||||
test("\u{10FFFF}", new List<int>.filled(1, null)..[0] = 0x10FFFF);
|
||||
test("\u{10FFFF}", new Uint32List(1)..[0] = 0x10FFFF);
|
||||
|
||||
test("\u{10ffff}", iter(2, [0xDBFF, 0xDFFF]));
|
||||
|
@ -83,7 +83,7 @@ main() {
|
|||
test("\u{10ffff}", const [0xDBFF, 0xDFFF]);
|
||||
test(
|
||||
"\u{10ffff}",
|
||||
new List<int>(2)
|
||||
new List<int>.filled(2, null)
|
||||
..[0] = 0xDBFF
|
||||
..[1] = 0xDFFF);
|
||||
test(
|
||||
|
@ -102,7 +102,7 @@ main() {
|
|||
test(leadSurrogate, iter(1, 0xDBFF));
|
||||
test(leadSurrogate, [0xDBFF]);
|
||||
test(leadSurrogate, const [0xDBFF]);
|
||||
test(leadSurrogate, new List<int>(1)..[0] = 0xDBFF);
|
||||
test(leadSurrogate, new List<int>.filled(1, null)..[0] = 0xDBFF);
|
||||
test(leadSurrogate, new Uint16List(1)..[0] = 0xDBFF);
|
||||
test(leadSurrogate, new Uint32List(1)..[0] = 0xDBFF);
|
||||
test(leadSurrogate, leadSurrogate.codeUnits);
|
||||
|
@ -111,7 +111,7 @@ main() {
|
|||
test(tailSurrogate, iter(1, 0xDFFF));
|
||||
test(tailSurrogate, [0xDFFF]);
|
||||
test(tailSurrogate, const [0xDFFF]);
|
||||
test(tailSurrogate, new List<int>(1)..[0] = 0xDFFF);
|
||||
test(tailSurrogate, new List<int>.filled(1, null)..[0] = 0xDFFF);
|
||||
test(tailSurrogate, new Uint16List(1)..[0] = 0xDFFF);
|
||||
test(tailSurrogate, new Uint32List(1)..[0] = 0xDFFF);
|
||||
test(tailSurrogate, tailSurrogate.codeUnits);
|
||||
|
@ -120,13 +120,13 @@ main() {
|
|||
testThrows("not an iterable");
|
||||
testThrows(42);
|
||||
testThrows([-1]);
|
||||
testThrows(new List<int>(1)..[0] = -1);
|
||||
testThrows(new List<int>.filled(1, null)..[0] = -1);
|
||||
testThrows(const [-1]);
|
||||
testThrows(new Int8List(1)..[0] = -1);
|
||||
testThrows(new Int16List(1)..[0] = -1);
|
||||
testThrows(new Int32List(1)..[0] = -1);
|
||||
testThrows([0x110000]);
|
||||
testThrows(new List<int>(1)..[0] = 0x110000);
|
||||
testThrows(new List<int>.filled(1, null)..[0] = 0x110000);
|
||||
testThrows(const [0x110000]);
|
||||
testThrows(new Int32List(1)..[0] = 0x110000);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class StringsTest {
|
|||
|
||||
static testCreation() {
|
||||
String s = "Hello";
|
||||
List<int> l = new List(s.length);
|
||||
List<int> l = new List.filled(s.length, null);
|
||||
for (int i = 0; i < l.length; i++) {
|
||||
l[i] = s.codeUnitAt(i);
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// Test that it is an error to call the default List constructor.
|
||||
main() {
|
||||
var a = new List<int>(3);
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.DEFAULT_LIST_CONSTRUCTOR
|
||||
// [cfe] Can't use the default List constructor.
|
||||
var b = new List<int?>(3);
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.DEFAULT_LIST_CONSTRUCTOR
|
||||
// [cfe] Can't use the default List constructor.
|
||||
var c = new List<int>();
|
||||
// ^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.DEFAULT_LIST_CONSTRUCTOR
|
||||
// [cfe] Can't use the default List constructor.
|
||||
var d = new List<int?>();
|
||||
// ^^^^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.DEFAULT_LIST_CONSTRUCTOR
|
||||
// [cfe] Can't use the default List constructor.
|
||||
List<C> e = new List(5);
|
||||
// ^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.DEFAULT_LIST_CONSTRUCTOR
|
||||
// [cfe] Can't use the default List constructor.
|
||||
}
|
||||
|
||||
class A<T> {
|
||||
var l = new List<T>(3);
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.DEFAULT_LIST_CONSTRUCTOR
|
||||
// [cfe] Can't use the default List constructor.
|
||||
}
|
||||
|
||||
class C {}
|
|
@ -17,7 +17,7 @@ main() {
|
|||
}
|
||||
|
||||
testInt64List() {
|
||||
var array = new List(10);
|
||||
var array = new List<dynamic>.filled(10, null);
|
||||
testInt64ListImpl(array);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
// VMOptions=--enable_asserts
|
||||
|
||||
main() {
|
||||
var names = new List<int>();
|
||||
var names = <int>[];
|
||||
|
||||
// Generic type test.
|
||||
assert(names is List<int>);
|
||||
|
|
|
@ -16,5 +16,5 @@ class B
|
|||
|
||||
main() {
|
||||
new C(); // //# 01: continued
|
||||
new List<C>(); // //# 02: continued
|
||||
<C>[]; // //# 02: continued
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
class A<T> {
|
||||
var t;
|
||||
A() : t = (() => new List<T>());
|
||||
A() : t = (() => <T>[]);
|
||||
}
|
||||
|
||||
class B<T> {
|
||||
|
|
|
@ -23,7 +23,7 @@ class Y {
|
|||
static var count = 0;
|
||||
Y() {
|
||||
// Consume large amounts of memory per iteration to fail/succeed quicker.
|
||||
heavyMemory = new List(10 * 1024 * 1024);
|
||||
heavyMemory = new List.filled(10 * 1024 * 1024, null);
|
||||
// Terminate the test if we allocated enough memory without running out.
|
||||
if (count++ > 100) return;
|
||||
Timer.run(() => onY());
|
||||
|
|
|
@ -9,11 +9,11 @@ import "package:expect/expect.dart";
|
|||
class A<T> {
|
||||
var closure;
|
||||
|
||||
factory A.factory() => new A(() => new List<T>());
|
||||
factory A.factory() => new A(() => <T>[]);
|
||||
|
||||
A([this.closure]) {
|
||||
if (closure == null) {
|
||||
closure = () => new List<T>();
|
||||
closure = () => <T>[];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ import "package:expect/expect.dart";
|
|||
|
||||
class ConstListTest {
|
||||
static testConstructors() {
|
||||
List fixedList = new List(4);
|
||||
List fixedList2 = new List(4);
|
||||
List growableList = new List();
|
||||
List growableList2 = new List();
|
||||
List fixedList = new List.filled(4, null);
|
||||
List fixedList2 = new List.filled(4, null);
|
||||
List growableList = [];
|
||||
List growableList2 = [];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
fixedList[i] = i;
|
||||
fixedList2[i] = i;
|
||||
|
|
|
@ -19,6 +19,6 @@ void set setter(int arg) {
|
|||
a = 10;
|
||||
}
|
||||
|
||||
var list = new List<int>();
|
||||
var list = <int>[];
|
||||
|
||||
var closure = (int arg) => 3;
|
||||
|
|
|
@ -17,7 +17,7 @@ class Helper {
|
|||
static int f1(int k) {
|
||||
var b;
|
||||
try {
|
||||
var a = new List(10);
|
||||
var a = new List<dynamic>.filled(10, null);
|
||||
int i = 0;
|
||||
while (i < 10) {
|
||||
int j = i;
|
||||
|
|
|
@ -206,7 +206,7 @@ class FunctionTest {
|
|||
}
|
||||
|
||||
void testLexicalClosureRef3() {
|
||||
var a = new List();
|
||||
var a = [];
|
||||
for (int i = 0; i < 10; i++) {
|
||||
var x = i;
|
||||
a.add(() {
|
||||
|
@ -240,7 +240,7 @@ class FunctionTest {
|
|||
|
||||
// Make sure labels are preserved, and a second 'i' does influence the first.
|
||||
void testLexicalClosureRef4() {
|
||||
var a = new List();
|
||||
var a = [];
|
||||
x:
|
||||
for (int i = 0; i < 10; i++) {
|
||||
a.add(() {
|
||||
|
|
|
@ -24,8 +24,8 @@ class LocalFunctionTest {
|
|||
|
||||
static int h(int n) {
|
||||
k(int n) {
|
||||
var a = new List(n);
|
||||
var b = new List(n);
|
||||
var a = new List<dynamic>.filled(n, null);
|
||||
var b = new List<dynamic>.filled(n, null);
|
||||
int i;
|
||||
for (i = 0; i < n; i++) {
|
||||
var j = i;
|
||||
|
@ -46,8 +46,8 @@ class LocalFunctionTest {
|
|||
|
||||
static int h2(int n) {
|
||||
k(int n) {
|
||||
var a = new List(n);
|
||||
var b = new List(n);
|
||||
var a = new List<dynamic>.filled(n, null);
|
||||
var b = new List<dynamic>.filled(n, null);
|
||||
for (int i = 0; i < n; i++) {
|
||||
var j = i;
|
||||
a[i] = () => i; // Captured i varies from 0 to n-1.
|
||||
|
@ -127,7 +127,7 @@ class LocalFunctionTest {
|
|||
}
|
||||
|
||||
static testNesting(int n) {
|
||||
var a = new List(n * n);
|
||||
var a = new List<dynamic>.filled(n * n, null);
|
||||
f0() {
|
||||
for (int i = 0; i < n; i++) {
|
||||
int vi = i;
|
||||
|
|
|
@ -27,6 +27,6 @@ main() {
|
|||
Expect.isTrue(new C().foo(1));
|
||||
Expect.isFalse(new C().foo(new Object()));
|
||||
Expect.isFalse(new C().foo('hest'));
|
||||
Expect.isTrue(new A<List<int>>().foo(new List<int>()));
|
||||
Expect.isFalse(new A<List<int>>().foo(new List<String>()));
|
||||
Expect.isTrue(new A<List<int>>().foo(<int>[]));
|
||||
Expect.isFalse(new A<List<int>>().foo(<String>[]));
|
||||
}
|
||||
|
|
|
@ -42,91 +42,91 @@ class GenericInstanceof {
|
|||
}
|
||||
{
|
||||
Foo foo = new Foo();
|
||||
Expect.equals(true, foo.isT(new List(5)));
|
||||
Expect.equals(true, foo.isT(new List<Object>(5)));
|
||||
Expect.equals(true, foo.isT(new List<int>(5)));
|
||||
Expect.equals(true, foo.isT(new List<num>(5)));
|
||||
Expect.equals(true, foo.isT(new List<String>(5)));
|
||||
Expect.equals(true, foo.isT(new List<dynamic>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<Object>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<int>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<num>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<String>.filled(5, null)));
|
||||
}
|
||||
{
|
||||
Foo foo = new Foo<List>();
|
||||
Expect.equals(true, foo.isT(new List(5)));
|
||||
Expect.equals(true, foo.isT(new List<Object>(5)));
|
||||
Expect.equals(true, foo.isT(new List<int>(5)));
|
||||
Expect.equals(true, foo.isT(new List<num>(5)));
|
||||
Expect.equals(true, foo.isT(new List<String>(5)));
|
||||
Expect.equals(true, foo.isT(new List<dynamic>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<Object>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<int>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<num>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<String>.filled(5, null)));
|
||||
}
|
||||
{
|
||||
Foo foo = new Foo<List<Object>>();
|
||||
Expect.equals(true, foo.isT(new List(5)));
|
||||
Expect.equals(true, foo.isT(new List<Object>(5)));
|
||||
Expect.equals(true, foo.isT(new List<int>(5)));
|
||||
Expect.equals(true, foo.isT(new List<num>(5)));
|
||||
Expect.equals(true, foo.isT(new List<String>(5)));
|
||||
Expect.equals(true, foo.isT(new List<dynamic>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<Object>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<int>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<num>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<String>.filled(5, null)));
|
||||
}
|
||||
{
|
||||
Foo foo = new Foo<List<int>>();
|
||||
Expect.equals(false, foo.isT(new List(5)));
|
||||
Expect.equals(false, foo.isT(new List<Object>(5)));
|
||||
Expect.equals(true, foo.isT(new List<int>(5)));
|
||||
Expect.equals(false, foo.isT(new List<num>(5)));
|
||||
Expect.equals(false, foo.isT(new List<String>(5)));
|
||||
Expect.equals(false, foo.isT(new List<dynamic>.filled(5, null)));
|
||||
Expect.equals(false, foo.isT(new List<Object>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<int>.filled(5, null)));
|
||||
Expect.equals(false, foo.isT(new List<num>.filled(5, null)));
|
||||
Expect.equals(false, foo.isT(new List<String>.filled(5, null)));
|
||||
}
|
||||
{
|
||||
Foo foo = new Foo<List<num>>();
|
||||
Expect.equals(false, foo.isT(new List(5)));
|
||||
Expect.equals(false, foo.isT(new List<Object>(5)));
|
||||
Expect.equals(true, foo.isT(new List<int>(5)));
|
||||
Expect.equals(true, foo.isT(new List<num>(5)));
|
||||
Expect.equals(false, foo.isT(new List<String>(5)));
|
||||
Expect.equals(false, foo.isT(new List<dynamic>.filled(5, null)));
|
||||
Expect.equals(false, foo.isT(new List<Object>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<int>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<num>.filled(5, null)));
|
||||
Expect.equals(false, foo.isT(new List<String>.filled(5, null)));
|
||||
}
|
||||
{
|
||||
Foo foo = new Foo<List<String>>();
|
||||
Expect.equals(false, foo.isT(new List(5)));
|
||||
Expect.equals(false, foo.isT(new List<Object>(5)));
|
||||
Expect.equals(false, foo.isT(new List<int>(5)));
|
||||
Expect.equals(false, foo.isT(new List<num>(5)));
|
||||
Expect.equals(true, foo.isT(new List<String>(5)));
|
||||
Expect.equals(false, foo.isT(new List<dynamic>.filled(5, null)));
|
||||
Expect.equals(false, foo.isT(new List<Object>.filled(5, null)));
|
||||
Expect.equals(false, foo.isT(new List<int>.filled(5, null)));
|
||||
Expect.equals(false, foo.isT(new List<num>.filled(5, null)));
|
||||
Expect.equals(true, foo.isT(new List<String>.filled(5, null)));
|
||||
}
|
||||
{
|
||||
Foo foo = new Foo();
|
||||
Expect.equals(true, foo.isListT(new List(5)));
|
||||
Expect.equals(true, foo.isListT(new List<Object>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<int>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<num>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<String>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<dynamic>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<Object>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<int>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<num>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<String>.filled(5, null)));
|
||||
}
|
||||
{
|
||||
Foo foo = new Foo<Object>();
|
||||
Expect.equals(true, foo.isListT(new List(5)));
|
||||
Expect.equals(true, foo.isListT(new List<Object>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<int>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<num>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<String>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<dynamic>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<Object>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<int>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<num>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<String>.filled(5, null)));
|
||||
}
|
||||
{
|
||||
Foo foo = new Foo<int>();
|
||||
Expect.equals(false, foo.isListT(new List(5)));
|
||||
Expect.equals(false, foo.isListT(new List<Object>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<int>(5)));
|
||||
Expect.equals(false, foo.isListT(new List<num>(5)));
|
||||
Expect.equals(false, foo.isListT(new List<String>(5)));
|
||||
Expect.equals(false, foo.isListT(new List<dynamic>.filled(5, null)));
|
||||
Expect.equals(false, foo.isListT(new List<Object>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<int>.filled(5, null)));
|
||||
Expect.equals(false, foo.isListT(new List<num>.filled(5, null)));
|
||||
Expect.equals(false, foo.isListT(new List<String>.filled(5, null)));
|
||||
}
|
||||
{
|
||||
Foo foo = new Foo<num>();
|
||||
Expect.equals(false, foo.isListT(new List(5)));
|
||||
Expect.equals(false, foo.isListT(new List<Object>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<int>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<num>(5)));
|
||||
Expect.equals(false, foo.isListT(new List<String>(5)));
|
||||
Expect.equals(false, foo.isListT(new List<dynamic>.filled(5, null)));
|
||||
Expect.equals(false, foo.isListT(new List<Object>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<int>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<num>.filled(5, null)));
|
||||
Expect.equals(false, foo.isListT(new List<String>.filled(5, null)));
|
||||
}
|
||||
{
|
||||
Foo foo = new Foo<String>();
|
||||
Expect.equals(false, foo.isListT(new List(5)));
|
||||
Expect.equals(false, foo.isListT(new List<Object>(5)));
|
||||
Expect.equals(false, foo.isListT(new List<int>(5)));
|
||||
Expect.equals(false, foo.isListT(new List<num>(5)));
|
||||
Expect.equals(true, foo.isListT(new List<String>(5)));
|
||||
Expect.equals(false, foo.isListT(new List<dynamic>.filled(5, null)));
|
||||
Expect.equals(false, foo.isListT(new List<Object>.filled(5, null)));
|
||||
Expect.equals(false, foo.isListT(new List<int>.filled(5, null)));
|
||||
Expect.equals(false, foo.isListT(new List<num>.filled(5, null)));
|
||||
Expect.equals(true, foo.isListT(new List<String>.filled(5, null)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ class B {}
|
|||
class C {}
|
||||
|
||||
main() {
|
||||
Expect.isTrue(new A<Iterable<B>>().foo(new List<B>()));
|
||||
Expect.isFalse(new A<Iterable<C>>().foo(new List<B>()));
|
||||
Expect.isTrue(new A<Iterable<B>>().foo(<B>[]));
|
||||
Expect.isFalse(new A<Iterable<C>>().foo(<B>[]));
|
||||
|
||||
Expect.isTrue(new A<Pattern>().foo('hest'));
|
||||
|
||||
|
|
|
@ -16,5 +16,5 @@ class B
|
|||
|
||||
main() {
|
||||
new C(); // //# 01: continued
|
||||
new List<C>(); // //# 02: continued
|
||||
<C>[]; // //# 02: continued
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class InstanceofTest {
|
|||
Expect.equals(false, null is I);
|
||||
|
||||
{
|
||||
var a = new List(5);
|
||||
var a = new List<dynamic>.filled(5, null);
|
||||
Expect.equals(true, a is List);
|
||||
Expect.equals(true, a is List<Object>);
|
||||
Expect.equals(false, a is List<int>);
|
||||
|
@ -66,7 +66,7 @@ class InstanceofTest {
|
|||
Expect.equals(false, a is List<String>);
|
||||
}
|
||||
{
|
||||
var a = new List<Object>(5);
|
||||
var a = new List<Object>.filled(5, null);
|
||||
Expect.equals(true, a is List);
|
||||
Expect.equals(true, a is List<Object>);
|
||||
Expect.equals(false, a is List<int>);
|
||||
|
@ -74,7 +74,7 @@ class InstanceofTest {
|
|||
Expect.equals(false, a is List<String>);
|
||||
}
|
||||
{
|
||||
var a = new List<int>(5);
|
||||
var a = new List<int>.filled(5, null);
|
||||
Expect.equals(true, a is List);
|
||||
Expect.equals(true, a is List<Object>);
|
||||
Expect.equals(true, a is List<int>);
|
||||
|
@ -82,7 +82,7 @@ class InstanceofTest {
|
|||
Expect.equals(false, a is List<String>);
|
||||
}
|
||||
{
|
||||
var a = new List<num>(5);
|
||||
var a = new List<num>.filled(5, null);
|
||||
Expect.equals(true, a is List);
|
||||
Expect.equals(true, a is List<Object>);
|
||||
Expect.equals(false, a is List<int>);
|
||||
|
@ -90,7 +90,7 @@ class InstanceofTest {
|
|||
Expect.equals(false, a is List<String>);
|
||||
}
|
||||
{
|
||||
var a = new List<String>(5);
|
||||
var a = new List<String>.filled(5, null);
|
||||
Expect.equals(true, a is List);
|
||||
Expect.equals(true, a is List<Object>);
|
||||
Expect.equals(false, a is List<int>);
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
import "package:expect/expect.dart";
|
||||
|
||||
class A<T> {
|
||||
bar() => new List<T>();
|
||||
bar() => <T>[];
|
||||
}
|
||||
|
||||
main() {
|
||||
check(new List(), true, false, false);
|
||||
check(new List<int>(), true, true, false);
|
||||
check(new List<double>(), true, false, true);
|
||||
check([], true, false, false);
|
||||
check(<int>[], true, true, false);
|
||||
check(<double>[], true, false, true);
|
||||
check(new A().bar(), true, false, false);
|
||||
check(new A<int>().bar(), true, true, false);
|
||||
check(new A<double>().bar(), true, false, true);
|
||||
|
|
|
@ -13,7 +13,7 @@ class B {}
|
|||
|
||||
class ListTest {
|
||||
static void TestIterator() {
|
||||
List<int> a = new List<int>(10);
|
||||
List<int> a = new List<int>.filled(10, null);
|
||||
int count = 0;
|
||||
|
||||
// Basic iteration over ObjectList.
|
||||
|
@ -24,7 +24,7 @@ class ListTest {
|
|||
Expect.equals(10, count);
|
||||
|
||||
// List length is 0.
|
||||
List<int> fa = new List<int>();
|
||||
List<int> fa = <int>[];
|
||||
count = 0;
|
||||
for (int elem in fa) {
|
||||
count++;
|
||||
|
@ -49,18 +49,18 @@ class ListTest {
|
|||
}
|
||||
|
||||
static void testSublistTypeArguments() {
|
||||
final list1 = new List<A>(0).sublist(0);
|
||||
final list1 = new List<A>.filled(0, null).sublist(0);
|
||||
Expect.isTrue(list1 is List<A>);
|
||||
Expect.isTrue(list1 is! List<B>);
|
||||
|
||||
final list2 = new List<A>(0).toList(growable: false);
|
||||
final list2 = new List<A>.filled(0, null).toList(growable: false);
|
||||
Expect.isTrue(list2 is List<A>);
|
||||
Expect.isTrue(list2 is! List<B>);
|
||||
}
|
||||
|
||||
static void testMain() {
|
||||
int len = 10;
|
||||
List a = new List(len);
|
||||
List a = new List.filled(len, null);
|
||||
Expect.equals(true, a is List);
|
||||
Expect.equals(len, a.length);
|
||||
a.forEach((element) {
|
||||
|
@ -71,22 +71,22 @@ class ListTest {
|
|||
Expect.throwsRangeError(() => a[len]);
|
||||
|
||||
Expect.throws(() {
|
||||
List a = new List(4);
|
||||
List a = new List.filled(4, null);
|
||||
a.setRange(1, 2, a, null);
|
||||
});
|
||||
|
||||
Expect.throws(() {
|
||||
List a = new List(4);
|
||||
List a = new List.filled(4, null);
|
||||
a.setRange(1, 2, const [1, 2, 3, 4], null);
|
||||
});
|
||||
|
||||
Expect.throwsRangeError(() {
|
||||
List a = new List(4);
|
||||
List a = new List.filled(4, null);
|
||||
a.setRange(10, 11, a, 1);
|
||||
});
|
||||
|
||||
a = new List(4);
|
||||
List b = new List(4);
|
||||
a = new List.filled(4, null);
|
||||
List b = new List.filled(4, null);
|
||||
b.setRange(0, 4, a, 0);
|
||||
|
||||
List<int> unsorted = [4, 3, 9, 12, -4, 9];
|
||||
|
@ -119,10 +119,10 @@ class ListTest {
|
|||
int element = unsorted[2];
|
||||
Expect.equals(9, element);
|
||||
|
||||
Expect.throws(() => new List(-1));
|
||||
Expect.throws(() => new List(0x7ffffffffffff000));
|
||||
Expect.throws(() => new List.filled(-1, null));
|
||||
Expect.throws(() => new List.filled(0x7ffffffffffff000, null));
|
||||
|
||||
List list = new List();
|
||||
List list = [];
|
||||
Expect.throwsRangeError(list.removeLast);
|
||||
Expect.equals(0, list.length);
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
// container pass to work.
|
||||
|
||||
main() {
|
||||
var a = new List();
|
||||
var a = [];
|
||||
a.add;
|
||||
var b = new List();
|
||||
var c = new List(1);
|
||||
var b = [];
|
||||
var c = new List<dynamic>.filled(1, null);
|
||||
b.add(c);
|
||||
b[0][0] = 42;
|
||||
if (c[0] is! int) {
|
||||
|
|
|
@ -102,8 +102,8 @@ checkAsListUnresolved(var v) {
|
|||
void main() {
|
||||
checkIsUnresolved('');
|
||||
checkAsUnresolved('');
|
||||
checkIsListUnresolved(new List());
|
||||
checkAsListUnresolved(new List());
|
||||
checkIsListUnresolved([]);
|
||||
checkAsListUnresolved([]);
|
||||
|
||||
new undeclared_prefix.Unresolved();
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -43,8 +43,8 @@ checkAsListUnresolved(var v) {
|
|||
void main() {
|
||||
checkIsUnresolved('');
|
||||
checkAsUnresolved('');
|
||||
checkIsListUnresolved(new List());
|
||||
checkAsListUnresolved(new List());
|
||||
checkIsListUnresolved([]);
|
||||
checkAsListUnresolved([]);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
class Indexed {
|
||||
Indexed()
|
||||
: _f = new List(10),
|
||||
: _f = new List<dynamic>.filled(10, null),
|
||||
count = 0 {
|
||||
_f[0] = 100;
|
||||
_f[1] = 200;
|
||||
|
|
|
@ -64,7 +64,7 @@ class IncrOpTest {
|
|||
Expect.equals(57, IncrOpTest.y);
|
||||
Expect.equals(56, --IncrOpTest.y);
|
||||
|
||||
var list = new List(4);
|
||||
var list = new List<dynamic>.filled(4, null);
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = i;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ int getIndex(trace) {
|
|||
}
|
||||
|
||||
main() {
|
||||
List trace = new List();
|
||||
List trace = [];
|
||||
getB(trace)[getIndex(trace)] += 37;
|
||||
|
||||
Expect.listEquals([-1, -2, -3, 42, 100, -4, 101, 37, -5, 42, 102], trace);
|
||||
|
|
|
@ -22,7 +22,7 @@ class IndexTest {
|
|||
static const ID_IDLE = 0;
|
||||
|
||||
static testMain() {
|
||||
var a = new List(10);
|
||||
var a = new List<dynamic>.filled(10, null);
|
||||
Expect.equals(10, a.length);
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
a[i] = Helper.fibonacci(i);
|
||||
|
|
|
@ -14,7 +14,7 @@ class A {
|
|||
}
|
||||
|
||||
var a = new A();
|
||||
var b = new List<dynamic>(4);
|
||||
var b = new List.filled(4, null);
|
||||
int count = 0;
|
||||
|
||||
main() {
|
||||
|
|
|
@ -19,7 +19,7 @@ testStoreIndexed() {
|
|||
}
|
||||
}
|
||||
|
||||
var a = new List(10);
|
||||
var a = new List<dynamic>.filled(10, null);
|
||||
for (var i = 0; i < 20; i++) {
|
||||
var r = test(a, 3, 888, false);
|
||||
Expect.equals(3, r);
|
||||
|
|
|
@ -15,7 +15,7 @@ class A {
|
|||
A(this.field);
|
||||
}
|
||||
|
||||
dynamic c = () => new List(42)[0];
|
||||
dynamic c = () => new List.filled(42, null)[0];
|
||||
|
||||
main() {
|
||||
bar();
|
||||
|
|
|
@ -119,7 +119,7 @@ throwConstructor() {
|
|||
}
|
||||
|
||||
cascade() {
|
||||
return new List()..add(callMeTrue())..add(kast("cascade"));
|
||||
return []..add(callMeTrue())..add(kast("cascade"));
|
||||
}
|
||||
|
||||
interpole() => "inter${kast('tada!')}pole";
|
||||
|
|
|
@ -16,8 +16,8 @@ main() {
|
|||
}
|
||||
|
||||
test(n) {
|
||||
var a = new List(); // Growable list.
|
||||
var b = new List(10); // Fixed size list.
|
||||
var a = []; // Growable list.
|
||||
var b = new List<dynamic>.filled(10, null); // Fixed size list.
|
||||
var c = const [1, 2, 3, 4]; // Constant aray.
|
||||
// In optimized mode the class checks will be eliminated since the
|
||||
// constructors above provide information about exact types.
|
||||
|
|
|
@ -21,7 +21,7 @@ class MyList<E> extends ListBase<E> {
|
|||
List<E> _list;
|
||||
|
||||
MyList([int length])
|
||||
: _list = (length == null ? new List() : new List(length));
|
||||
: _list = (length == null ? [] : new List<dynamic>.filled(length, null));
|
||||
|
||||
E operator [](int index) => _list[index];
|
||||
|
||||
|
@ -72,7 +72,7 @@ sort_A01_t02_test(List create([int length])) {
|
|||
void check() {
|
||||
return;
|
||||
// Deleting the code below will throw a RangeError instead of throw above.
|
||||
var a_copy = new List(length);
|
||||
var a_copy = new List<dynamic>.filled(length, null);
|
||||
a_copy.setRange(0, length, a);
|
||||
a_copy.sort(c);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ test(List a, int v) {
|
|||
}
|
||||
|
||||
main() {
|
||||
var list = new List(2);
|
||||
var list = new List<dynamic>.filled(2, null);
|
||||
for (var i = 0; i < 20; i++) test(list, 1);
|
||||
Expect.equals(null, list[0]);
|
||||
Expect.equals(1, list[1]);
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
// Regression test for issue 27700.
|
||||
|
||||
main() {
|
||||
var x = new List(0);
|
||||
var x = new List.filled(0, null);
|
||||
var z = "$x";
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import "package:expect/expect.dart";
|
||||
|
||||
main() {
|
||||
List<int> ints = new List<int>()
|
||||
List<int> ints = <int>[]
|
||||
..add(0)
|
||||
..add(1)
|
||||
..add(2)
|
||||
|
|
|
@ -9,7 +9,7 @@ import "package:expect/expect.dart";
|
|||
|
||||
class StringJoinTest {
|
||||
static testMain() {
|
||||
List<String> ga = new List<String>();
|
||||
List<String> ga = <String>[];
|
||||
ga.add("a");
|
||||
ga.add("b");
|
||||
Expect.equals("ab", ga.join());
|
||||
|
|
|
@ -27,7 +27,7 @@ class StringTest {
|
|||
}
|
||||
|
||||
static testStringsJoin() {
|
||||
List<String> a = new List<String>(2);
|
||||
List<String> a = new List<String>.filled(2, null);
|
||||
a[0] = "Hello";
|
||||
a[1] = "World";
|
||||
String s = a.join("*^*");
|
||||
|
|
|
@ -24,7 +24,7 @@ class StringTest {
|
|||
}
|
||||
|
||||
static testStringsJoin() {
|
||||
List<String> a = new List<String>(2);
|
||||
List<String> a = new List<String>.filled(2, null);
|
||||
a[0] = "Hello";
|
||||
a[1] = "World";
|
||||
String s = a.join("*^*");
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import "package:expect/expect.dart";
|
||||
|
||||
class A {
|
||||
var indexField = new List<int>(2);
|
||||
var indexField = new List<int>.filled(2, null);
|
||||
operator []=(index, value) {
|
||||
indexField[index] = value;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import "package:expect/expect.dart";
|
||||
|
||||
class A {
|
||||
var indexField = new List<int>(2);
|
||||
var indexField = new List<int>.filled(2, null);
|
||||
operator [](index) => indexField[index];
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import "package:expect/expect.dart";
|
||||
|
||||
class A {
|
||||
var indexField = new List(2);
|
||||
var indexField = new List<dynamic>.filled(2, null);
|
||||
operator [](index) => indexField[index];
|
||||
|
||||
operator []=(index, value);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import "package:expect/expect.dart";
|
||||
|
||||
class A {
|
||||
var indexField = new List(2);
|
||||
var indexField = new List<dynamic>.filled(2, null);
|
||||
operator []=(index, value) {
|
||||
indexField[index] = value;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import "package:expect/expect.dart";
|
||||
|
||||
class A {
|
||||
var indexField = new List(2);
|
||||
var indexField = new List<dynamic>.filled(2, null);
|
||||
|
||||
operator []=(index, value);
|
||||
operator [](index);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import "package:expect/expect.dart";
|
||||
|
||||
class A {
|
||||
var indexField = new List(2);
|
||||
var indexField = new List<dynamic>.filled(2, null);
|
||||
|
||||
operator []=(index, value);
|
||||
operator [](index);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue