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

Side by Side Diff: tests/corelib/growable_list_test.dart

Issue 1440663003: Add "growable" parameter to List.filled constructor. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « sdk/lib/core/list.dart ('k') | tests/corelib/list_filled_type_argument_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Sanity check on the growing behavior of a growable list. 5 // Sanity check on the growing behavior of a growable list.
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 void main() { 9 void main() {
10 testConstructor(); 10 testConstructor();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 bool checked = false; 83 bool checked = false;
84 assert((checked = true)); 84 assert((checked = true));
85 testThrowsOrTypeError(fn, test, [name]) { 85 testThrowsOrTypeError(fn, test, [name]) {
86 Expect.throws(fn, checked ? null : test, 86 Expect.throws(fn, checked ? null : test,
87 checked ? name : "$name w/ TypeError"); 87 checked ? name : "$name w/ TypeError");
88 } 88 }
89 testFixedLength(new List<int>(0)); 89 testFixedLength(new List<int>(0));
90 testFixedLength(new List<int>(5)); 90 testFixedLength(new List<int>(5));
91 testFixedLength(new List<int>.filled(5, null)); // default growable: false.
91 testGrowable(new List<int>()); 92 testGrowable(new List<int>());
92 testGrowable(new List<int>()..length = 5); 93 testGrowable(new List<int>()..length = 5);
94 testGrowable(new List<int>.filled(5, null, growable: true));
93 Expect.throws(() => new List<int>(-1), (e) => e is ArgumentError, "-1"); 95 Expect.throws(() => new List<int>(-1), (e) => e is ArgumentError, "-1");
94 // There must be limits. Fix this test if we ever allow 10^30 elements. 96 // There must be limits. Fix this test if we ever allow 10^30 elements.
95 Expect.throws(() => new List<int>(0x1000000000000000000000000000000), 97 Expect.throws(() => new List<int>(0x1000000000000000000000000000000),
96 (e) => e is ArgumentError, "bignum"); 98 (e) => e is ArgumentError, "bignum");
97 Expect.throws(() => new List<int>(null), (e) => e is ArgumentError, "null"); 99 Expect.throws(() => new List<int>(null), (e) => e is ArgumentError, "null");
98 testThrowsOrTypeError(() => new List([] as Object), // Cast to avoid warning. 100 testThrowsOrTypeError(() => new List([] as Object), // Cast to avoid warning.
99 (e) => e is ArgumentError, 'list'); 101 (e) => e is ArgumentError, 'list');
100 testThrowsOrTypeError(() => new List([42] as Object), 102 testThrowsOrTypeError(() => new List([42] as Object),
101 (e) => e is ArgumentError, "list2"); 103 (e) => e is ArgumentError, "list2");
102 } 104 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 173 }
172 174
173 { 175 {
174 // Adding to yourself. 176 // Adding to yourself.
175 var l = [1, 2, 3]; 177 var l = [1, 2, 3];
176 Expect.throws(() { l.addAll(l); }, 178 Expect.throws(() { l.addAll(l); },
177 (e) => e is ConcurrentModificationError, "cm8"); 179 (e) => e is ConcurrentModificationError, "cm8");
178 } 180 }
179 } 181 }
180 182
OLDNEW
« no previous file with comments | « sdk/lib/core/list.dart ('k') | tests/corelib/list_filled_type_argument_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698