Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: tests/corelib/src/ListRemoveRangeTest.dart

Issue 10244009: test rename overhaul: step 7 - corelib tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 main() {
6 var list = [];
7 list.removeRange(0, 0);
8 Expect.equals(0, list.length);
9 expectIOORE(() { list.removeRange(0, 1); });
10
11 list.add(1);
12 list.removeRange(0, 0);
13 Expect.equals(1, list.length);
14 Expect.equals(1, list[0]);
15
16 expectIOORE(() { list.removeRange(0, 2); });
17 Expect.equals(1, list.length);
18 Expect.equals(1, list[0]);
19
20 list.removeRange(0, 1);
21 Expect.equals(0, list.length);
22
23 list.addAll([3, 4, 5, 6]);
24 Expect.equals(4, list.length);
25 list.removeRange(0, 4);
26 Expect.listEquals([], list);
27
28 list.addAll([3, 4, 5, 6]);
29 list.removeRange(2, 2);
30 Expect.listEquals([3, 4], list);
31 list.addAll([5, 6]);
32
33 expectIOORE(() { list.removeRange(4, 1); });
34 Expect.listEquals([3, 4, 5, 6], list);
35
36 list.removeRange(1, 2);
37 Expect.listEquals([3, 6], list);
38
39 testNegativeIndices();
40 }
41
42 void expectIOORE(Function f) {
43 Expect.throws(f, (e) => e is IndexOutOfRangeException);
44 }
45
46 void testNegativeIndices() {
47 var list = [1, 2];
48 expectIOORE(() { list.removeRange(-1, 1); });
49 Expect.listEquals([1, 2], list);
50
51 // A negative length throws an IllegalArgumentException.
52 Expect.throws(() { list.removeRange(0, -1); },
53 (e) => e is IllegalArgumentException);
54 Expect.listEquals([1, 2], list);
55
56 Expect.throws(() { list.removeRange(-1, -1); },
57 (e) => e is IllegalArgumentException);
58 Expect.listEquals([1, 2], list);
59
60 // A zero length prevails, and does not throw an exception.
61 list.removeRange(-1, 0);
62 Expect.listEquals([1, 2], list);
63
64 list.removeRange(4, 0);
65 Expect.listEquals([1, 2], list);
66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698