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 main() { | 5 main() { |
6 var list = []; | 6 var list = []; |
7 list.removeRange(0, 0); | 7 list.removeRange(0, 0); |
8 Expect.equals(0, list.length); | 8 Expect.equals(0, list.length); |
9 expectIOORE(() { list.removeRange(0, 1); }); | 9 expectIOORE(() { list.removeRange(0, 1); }); |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 void expectIOORE(Function f) { | 42 void expectIOORE(Function f) { |
43 Expect.throws(f, (e) => e is IndexOutOfRangeException); | 43 Expect.throws(f, (e) => e is IndexOutOfRangeException); |
44 } | 44 } |
45 | 45 |
46 void testNegativeIndices() { | 46 void testNegativeIndices() { |
47 var list = [1, 2]; | 47 var list = [1, 2]; |
48 expectIOORE(() { list.removeRange(-1, 1); }); | 48 expectIOORE(() { list.removeRange(-1, 1); }); |
49 Expect.listEquals([1, 2], list); | 49 Expect.listEquals([1, 2], list); |
50 | 50 |
51 // A negative length throws an IllegalArgumentException. | 51 // A negative length throws an ArgumentError. |
52 Expect.throws(() { list.removeRange(0, -1); }, | 52 Expect.throws(() { list.removeRange(0, -1); }, |
53 (e) => e is IllegalArgumentException); | 53 (e) => e is ArgumentError); |
54 Expect.listEquals([1, 2], list); | 54 Expect.listEquals([1, 2], list); |
55 | 55 |
56 Expect.throws(() { list.removeRange(-1, -1); }, | 56 Expect.throws(() { list.removeRange(-1, -1); }, |
57 (e) => e is IllegalArgumentException); | 57 (e) => e is ArgumentError); |
58 Expect.listEquals([1, 2], list); | 58 Expect.listEquals([1, 2], list); |
59 | 59 |
60 // A zero length prevails, and does not throw an exception. | 60 // A zero length prevails, and does not throw an exception. |
61 list.removeRange(-1, 0); | 61 list.removeRange(-1, 0); |
62 Expect.listEquals([1, 2], list); | 62 Expect.listEquals([1, 2], list); |
63 | 63 |
64 list.removeRange(4, 0); | 64 list.removeRange(4, 0); |
65 Expect.listEquals([1, 2], list); | 65 Expect.listEquals([1, 2], list); |
66 } | 66 } |
OLD | NEW |