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

Side by Side Diff: tests/corelib/list_replace_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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "dart:collection"; 6 import "dart:collection";
7 7
8 test(List list, int start, int end, Iterable iterable) { 8 test(List list, int start, int end, Iterable iterable) {
9 List copy = list.toList(); 9 List copy = list.toList();
10 list.replaceRange(start, end, iterable); 10 list.replaceRange(start, end, iterable);
11 List iterableList = iterable.toList(); 11 List iterableList = iterable.toList();
12 Expect.equals(copy.length + iterableList.length - (end - start), list.length); 12 Expect.equals(copy.length + iterableList.length - (end - start), list.length);
13 for (int i = 0; i < start; i++) { 13 for (int i = 0; i < start; i++) {
14 Expect.equals(copy[i], list[i]); 14 Expect.equals(copy[i], list[i]);
15 } 15 }
16 for (int i = 0; i < iterableList.length; i++) { 16 for (int i = 0; i < iterableList.length; i++) {
17 Expect.equals(iterableList[i], list[i + start]); 17 Expect.equals(iterableList[i], list[i + start]);
18 } 18 }
19 int removedLength = end - start; 19 int removedLength = end - start;
20 for (int i = end; i < copy.length; i++) { 20 for (int i = end; i < copy.length; i++) {
21 Expect.equals(copy[i], list[i + iterableList.length - removedLength]); 21 Expect.equals(copy[i], list[i + iterableList.length - removedLength]);
22 } 22 }
23 } 23 }
24 24
25 class MyList extends ListBase { 25 class MyList extends ListBase {
26 List list; 26 List list;
27 MyList(this.list); 27 MyList(this.list);
28 get length => list.length; 28 get length => list.length;
29 set length(value) { list.length = value; } 29 set length(value) {
30 list.length = value;
31 }
32
30 operator [](index) => list[index]; 33 operator [](index) => list[index];
31 operator []=(index, val) { list[index] = val; } 34 operator []=(index, val) {
35 list[index] = val;
36 }
37
32 toString() => list.toString(); 38 toString() => list.toString();
33 } 39 }
34 40
35 main() { 41 main() {
36 test([1, 2, 3], 0, 1, [4, 5]); 42 test([1, 2, 3], 0, 1, [4, 5]);
37 test([1, 2, 3], 1, 1, [4, 5]); 43 test([1, 2, 3], 1, 1, [4, 5]);
38 test([1, 2, 3], 2, 3, [4, 5]); 44 test([1, 2, 3], 2, 3, [4, 5]);
39 test([1, 2, 3], 3, 3, [4, 5]); 45 test([1, 2, 3], 3, 3, [4, 5]);
40 test([1, 2, 3], 0, 3, [4, 5]); 46 test([1, 2, 3], 0, 3, [4, 5]);
41 test([1, 2, 3], 2, 3, [4]); 47 test([1, 2, 3], 2, 3, [4]);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 expectUE(() => test(const [1, 2, 3], 1, 4, [])); 114 expectUE(() => test(const [1, 2, 3], 1, 4, []));
109 } 115 }
110 116
111 void expectRE(Function f) { 117 void expectRE(Function f) {
112 Expect.throws(f, (e) => e is RangeError); 118 Expect.throws(f, (e) => e is RangeError);
113 } 119 }
114 120
115 void expectUE(Function f) { 121 void expectUE(Function f) {
116 Expect.throws(f, (e) => e is UnsupportedError); 122 Expect.throws(f, (e) => e is UnsupportedError);
117 } 123 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698