| OLD | NEW |
| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 testFixedLength(new List<int>(0)); | 91 testFixedLength(new List<int>(0)); |
| 92 testFixedLength(new List<int>(5)); | 92 testFixedLength(new List<int>(5)); |
| 93 testFixedLength(new List<int>.filled(5, null)); // default growable: false. | 93 testFixedLength(new List<int>.filled(5, null)); // default growable: false. |
| 94 testGrowable(new List<int>()); | 94 testGrowable(new List<int>()); |
| 95 testGrowable(new List<int>()..length = 5); | 95 testGrowable(new List<int>()..length = 5); |
| 96 testGrowable(new List<int>.filled(5, null, growable: true)); | 96 testGrowable(new List<int>.filled(5, null, growable: true)); |
| 97 Expect.throws(() => new List<int>(-1), (e) => e is ArgumentError, "-1"); | 97 Expect.throws(() => new List<int>(-1), (e) => e is ArgumentError, "-1"); |
| 98 // There must be limits. Fix this test if we ever allow 10^30 elements. | 98 // There must be limits. Fix this test if we ever allow 10^30 elements. |
| 99 Expect.throws(() => new List<int>(0x1000000000000000000000000000000), | 99 Expect.throws(() => new List<int>(0x7fffffffffffffff), |
| 100 (e) => e is ArgumentError, "bignum"); | 100 (e) => e is ArgumentError, "bignum"); |
| 101 Expect.throws(() => new List<int>(null), (e) => e is ArgumentError, "null"); | 101 Expect.throws(() => new List<int>(null), (e) => e is ArgumentError, "null"); |
| 102 testThrowsOrTypeError( | 102 testThrowsOrTypeError( |
| 103 () => new List([] as Object), // Cast to avoid warning. | 103 () => new List([] as Object), // Cast to avoid warning. |
| 104 (e) => e is ArgumentError, | 104 (e) => e is ArgumentError, |
| 105 'list'); | 105 'list'); |
| 106 testThrowsOrTypeError( | 106 testThrowsOrTypeError( |
| 107 () => new List([42] as Object), (e) => e is ArgumentError, "list2"); | 107 () => new List([42] as Object), (e) => e is ArgumentError, "list2"); |
| 108 } | 108 } |
| 109 | 109 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 178 } |
| 179 | 179 |
| 180 { | 180 { |
| 181 // Adding to yourself. | 181 // Adding to yourself. |
| 182 var l = [1, 2, 3]; | 182 var l = [1, 2, 3]; |
| 183 Expect.throws(() { | 183 Expect.throws(() { |
| 184 l.addAll(l); | 184 l.addAll(l); |
| 185 }, (e) => e is ConcurrentModificationError, "cm8"); | 185 }, (e) => e is ConcurrentModificationError, "cm8"); |
| 186 } | 186 } |
| 187 } | 187 } |
| OLD | NEW |