| 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 void main() { | 5 void main() { |
| 6 // Normal modifiable list. | 6 // Normal modifiable list. |
| 7 var l1 = [0, 1, 2, 3, 4]; | 7 var l1 = [0, 1, 2, 3, 4]; |
| 8 | 8 |
| 9 bool checkedMode = false; | 9 bool checkedMode = false; |
| 10 assert(checkedMode = true); | 10 assert(checkedMode = true); |
| 11 | 11 |
| 12 // Index must be integer and in range. | 12 // Index must be integer and in range. |
| 13 Expect.throws(() { l1.removeAt(-1); }, | 13 Expect.throws(() { l1.removeAt(-1); }, |
| 14 (e) => e is IndexOutOfRangeException, | 14 (e) => e is RangeError, |
| 15 "negative"); | 15 "negative"); |
| 16 Expect.throws(() { l1.removeAt(5); }, | 16 Expect.throws(() { l1.removeAt(5); }, |
| 17 (e) => e is IndexOutOfRangeException, | 17 (e) => e is RangeError, |
| 18 "too large"); | 18 "too large"); |
| 19 Expect.throws(() { l1.removeAt(null); }, | 19 Expect.throws(() { l1.removeAt(null); }, |
| 20 (e) => e is ArgumentError, | 20 (e) => e is ArgumentError, |
| 21 "too large"); | 21 "too large"); |
| 22 Expect.throws(() { l1.removeAt("1"); }, | 22 Expect.throws(() { l1.removeAt("1"); }, |
| 23 (e) => (checkedMode ? e is TypeError | 23 (e) => (checkedMode ? e is TypeError |
| 24 : e is ArgumentError), | 24 : e is ArgumentError), |
| 25 "string"); | 25 "string"); |
| 26 Expect.throws(() { l1.removeAt(1.5); }, | 26 Expect.throws(() { l1.removeAt(1.5); }, |
| 27 (e) => (checkedMode ? e is TypeError | 27 (e) => (checkedMode ? e is TypeError |
| (...skipping 22 matching lines...) Expand all Loading... |
| 50 | 50 |
| 51 // Unmodifiable list. | 51 // Unmodifiable list. |
| 52 var l3 = const [0, 1, 2, 3, 4]; | 52 var l3 = const [0, 1, 2, 3, 4]; |
| 53 Expect.throws(() { l3.removeAt(2); }, | 53 Expect.throws(() { l3.removeAt(2); }, |
| 54 (e) => e is UnsupportedError, | 54 (e) => e is UnsupportedError, |
| 55 "unmodifiable"); | 55 "unmodifiable"); |
| 56 | 56 |
| 57 // Empty list is not special. | 57 // Empty list is not special. |
| 58 var l4 = []; | 58 var l4 = []; |
| 59 Expect.throws(() { l4.removeAt(0); }, | 59 Expect.throws(() { l4.removeAt(0); }, |
| 60 (e) => e is IndexOutOfRangeException, | 60 (e) => e is RangeError, |
| 61 "empty"); | 61 "empty"); |
| 62 } | 62 } |
| OLD | NEW |