| 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 import "package:expect/expect.dart"; |   5 import "package:expect/expect.dart"; | 
|   6  |   6  | 
|   7 main() { |   7 main() { | 
|   8   var list = []; |   8   var list = []; | 
|   9   list.removeRange(0, 0); |   9   list.removeRange(0, 0); | 
|  10   Expect.equals(0, list.length); |  10   Expect.equals(0, list.length); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|  21  |  21  | 
|  22   list.removeRange(0, 1); |  22   list.removeRange(0, 1); | 
|  23   Expect.equals(0, list.length); |  23   Expect.equals(0, list.length); | 
|  24  |  24  | 
|  25   list.addAll([3, 4, 5, 6]); |  25   list.addAll([3, 4, 5, 6]); | 
|  26   Expect.equals(4, list.length); |  26   Expect.equals(4, list.length); | 
|  27   list.removeRange(0, 4); |  27   list.removeRange(0, 4); | 
|  28   Expect.listEquals([], list); |  28   Expect.listEquals([], list); | 
|  29  |  29  | 
|  30   list.addAll([3, 4, 5, 6]); |  30   list.addAll([3, 4, 5, 6]); | 
|  31   list.removeRange(2, 2); |  31   list.removeRange(2, 4); | 
|  32   Expect.listEquals([3, 4], list); |  32   Expect.listEquals([3, 4], list); | 
|  33   list.addAll([5, 6]); |  33   list.addAll([5, 6]); | 
|  34  |  34  | 
|  35   expectIOORE(() { list.removeRange(4, 1); }); |  35   expectIOORE(() { list.removeRange(4, 5); }); | 
|  36   Expect.listEquals([3, 4, 5, 6], list); |  36   Expect.listEquals([3, 4, 5, 6], list); | 
|  37  |  37  | 
|  38   list.removeRange(1, 2); |  38   list.removeRange(1, 3); | 
|  39   Expect.listEquals([3, 6], list); |  39   Expect.listEquals([3, 6], list); | 
|  40  |  40  | 
|  41   testNegativeIndices(); |  41   testNegativeIndices(); | 
|  42 } |  42 } | 
|  43  |  43  | 
|  44 void expectIOORE(Function f) { |  44 void expectIOORE(Function f) { | 
|  45   Expect.throws(f, (e) => e is RangeError); |  45   Expect.throws(f, (e) => e is RangeError); | 
|  46 } |  46 } | 
|  47  |  47  | 
|  48 void testNegativeIndices() { |  48 void testNegativeIndices() { | 
|  49   var list = [1, 2]; |  49   var list = [1, 2]; | 
|  50   expectIOORE(() { list.removeRange(-1, 1); }); |  50   expectIOORE(() { list.removeRange(-1, 1); }); | 
|  51   Expect.listEquals([1, 2], list); |  51   Expect.listEquals([1, 2], list); | 
|  52  |  52  | 
|  53   // A negative length throws an ArgumentError. |  53   // A negative length throws an ArgumentError. | 
|  54   Expect.throws(() { list.removeRange(0, -1); }, |  54   expectIOORE(() { list.removeRange(0, -1); }); | 
|  55       (e) => e is ArgumentError); |  | 
|  56   Expect.listEquals([1, 2], list); |  55   Expect.listEquals([1, 2], list); | 
|  57  |  56  | 
|  58   Expect.throws(() { list.removeRange(-1, -1); }, |  57   expectIOORE(() { list.removeRange(-1, -1); }); | 
|  59       (e) => e is ArgumentError); |  | 
|  60   Expect.listEquals([1, 2], list); |  58   Expect.listEquals([1, 2], list); | 
|  61  |  59  | 
|  62   // A zero length prevails, and does not throw an exception. |  60   expectIOORE(() { list.removeRange(-1, 0); }); | 
|  63   list.removeRange(-1, 0); |  | 
|  64   Expect.listEquals([1, 2], list); |  | 
|  65  |  61  | 
|  66   list.removeRange(4, 0); |  62   expectIOORE(() { list.removeRange(4, 4); }); | 
|  67   Expect.listEquals([1, 2], list); |  63   Expect.listEquals([1, 2], list); | 
|  68 } |  64 } | 
| OLD | NEW |