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

Side by Side Diff: tests/corelib/list_remove_range_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 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
OLDNEW
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);
11 expectIOORE(() { list.removeRange(0, 1); }); 11 expectIOORE(() {
12 list.removeRange(0, 1);
13 });
12 14
13 list.add(1); 15 list.add(1);
14 list.removeRange(0, 0); 16 list.removeRange(0, 0);
15 Expect.equals(1, list.length); 17 Expect.equals(1, list.length);
16 Expect.equals(1, list[0]); 18 Expect.equals(1, list[0]);
17 19
18 expectIOORE(() { list.removeRange(0, 2); }); 20 expectIOORE(() {
21 list.removeRange(0, 2);
22 });
19 Expect.equals(1, list.length); 23 Expect.equals(1, list.length);
20 Expect.equals(1, list[0]); 24 Expect.equals(1, list[0]);
21 25
22 list.removeRange(0, 1); 26 list.removeRange(0, 1);
23 Expect.equals(0, list.length); 27 Expect.equals(0, list.length);
24 28
25 list.addAll([3, 4, 5, 6]); 29 list.addAll([3, 4, 5, 6]);
26 Expect.equals(4, list.length); 30 Expect.equals(4, list.length);
27 list.removeRange(0, 4); 31 list.removeRange(0, 4);
28 Expect.listEquals([], list); 32 Expect.listEquals([], list);
29 33
30 list.addAll([3, 4, 5, 6]); 34 list.addAll([3, 4, 5, 6]);
31 list.removeRange(2, 4); 35 list.removeRange(2, 4);
32 Expect.listEquals([3, 4], list); 36 Expect.listEquals([3, 4], list);
33 list.addAll([5, 6]); 37 list.addAll([5, 6]);
34 38
35 expectIOORE(() { list.removeRange(4, 5); }); 39 expectIOORE(() {
40 list.removeRange(4, 5);
41 });
36 Expect.listEquals([3, 4, 5, 6], list); 42 Expect.listEquals([3, 4, 5, 6], list);
37 43
38 list.removeRange(1, 3); 44 list.removeRange(1, 3);
39 Expect.listEquals([3, 6], list); 45 Expect.listEquals([3, 6], list);
40 46
41 testNegativeIndices(); 47 testNegativeIndices();
42 } 48 }
43 49
44 void expectIOORE(Function f) { 50 void expectIOORE(Function f) {
45 Expect.throws(f, (e) => e is RangeError); 51 Expect.throws(f, (e) => e is RangeError);
46 } 52 }
47 53
48 void testNegativeIndices() { 54 void testNegativeIndices() {
49 var list = [1, 2]; 55 var list = [1, 2];
50 expectIOORE(() { list.removeRange(-1, 1); }); 56 expectIOORE(() {
57 list.removeRange(-1, 1);
58 });
51 Expect.listEquals([1, 2], list); 59 Expect.listEquals([1, 2], list);
52 60
53 // A negative length throws an ArgumentError. 61 // A negative length throws an ArgumentError.
54 expectIOORE(() { list.removeRange(0, -1); }); 62 expectIOORE(() {
63 list.removeRange(0, -1);
64 });
55 Expect.listEquals([1, 2], list); 65 Expect.listEquals([1, 2], list);
56 66
57 expectIOORE(() { list.removeRange(-1, -1); }); 67 expectIOORE(() {
68 list.removeRange(-1, -1);
69 });
58 Expect.listEquals([1, 2], list); 70 Expect.listEquals([1, 2], list);
59 71
60 expectIOORE(() { list.removeRange(-1, 0); }); 72 expectIOORE(() {
73 list.removeRange(-1, 0);
74 });
61 75
62 expectIOORE(() { list.removeRange(4, 4); }); 76 expectIOORE(() {
77 list.removeRange(4, 4);
78 });
63 Expect.listEquals([1, 2], list); 79 Expect.listEquals([1, 2], list);
64 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698