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 testGetRange(list, start, end, bool isModifiable) { | 7 testGetRange(list, start, end, bool isModifiable) { |
8 expectRE(() { list.getRange(-1, 0); }); | 8 expectRE(() { |
9 expectRE(() { list.getRange(0, -1); }); | 9 list.getRange(-1, 0); |
10 expectRE(() { list.getRange(1, 0); }); | 10 }); |
11 expectRE(() { list.getRange(0, list.length + 1); }); | 11 expectRE(() { |
12 expectRE(() { list.getRange(list.length + 1, list.length + 1); }); | 12 list.getRange(0, -1); |
| 13 }); |
| 14 expectRE(() { |
| 15 list.getRange(1, 0); |
| 16 }); |
| 17 expectRE(() { |
| 18 list.getRange(0, list.length + 1); |
| 19 }); |
| 20 expectRE(() { |
| 21 list.getRange(list.length + 1, list.length + 1); |
| 22 }); |
13 Iterable iterable = list.getRange(start, end); | 23 Iterable iterable = list.getRange(start, end); |
14 Expect.isFalse(iterable is List); | 24 Expect.isFalse(iterable is List); |
15 if (start == end) { | 25 if (start == end) { |
16 Expect.isTrue(iterable.isEmpty); | 26 Expect.isTrue(iterable.isEmpty); |
17 return; | 27 return; |
18 } | 28 } |
19 | 29 |
20 var iterator = iterable.iterator; | 30 var iterator = iterable.iterator; |
21 for (int i = start; i < end; i++) { | 31 for (int i = start; i < end; i++) { |
22 Expect.isTrue(iterator.moveNext()); | 32 Expect.isTrue(iterator.moveNext()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 list.add(99); | 73 list.add(99); |
64 Expect.equals(99, iterable.single); | 74 Expect.equals(99, iterable.single); |
65 list.add(499); | 75 list.add(499); |
66 Expect.equals(499, iterable.last); | 76 Expect.equals(499, iterable.last); |
67 Expect.equals(2, iterable.length); | 77 Expect.equals(2, iterable.length); |
68 } | 78 } |
69 | 79 |
70 void expectRE(Function f) { | 80 void expectRE(Function f) { |
71 Expect.throws(f, (e) => e is RangeError); | 81 Expect.throws(f, (e) => e is RangeError); |
72 } | 82 } |
OLD | NEW |