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

Side by Side Diff: tests/corelib_strong/list_fill_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, [fillValue]) { 8 test(List list, int start, int end, [fillValue]) {
9 List copy = list.toList(); 9 List copy = list.toList();
10 list.fillRange(start, end, fillValue); 10 list.fillRange(start, end, fillValue);
11 Expect.equals(copy.length, list.length); 11 Expect.equals(copy.length, list.length);
12 for (int i = 0; i < start; i++) { 12 for (int i = 0; i < start; i++) {
13 Expect.equals(copy[i], list[i]); 13 Expect.equals(copy[i], list[i]);
14 } 14 }
15 for (int i = start; i < end; i++) { 15 for (int i = start; i < end; i++) {
16 Expect.equals(fillValue, list[i]); 16 Expect.equals(fillValue, list[i]);
17 } 17 }
18 for (int i = end; i < list.length; i++) { 18 for (int i = end; i < list.length; i++) {
19 Expect.equals(copy[i], list[i]); 19 Expect.equals(copy[i], list[i]);
20 } 20 }
21 } 21 }
22 22
23 class MyList extends ListBase { 23 class MyList extends ListBase {
24 List list; 24 List list;
25 MyList(this.list); 25 MyList(this.list);
26 get length => list.length; 26 get length => list.length;
27 set length(value) { list.length = value; } 27 set length(value) {
28 list.length = value;
29 }
30
28 operator [](index) => list[index]; 31 operator [](index) => list[index];
29 operator []=(index, val) { list[index] = val; } 32 operator []=(index, val) {
33 list[index] = val;
34 }
35
30 toString() => list.toString(); 36 toString() => list.toString();
31 } 37 }
32 38
33 main() { 39 main() {
34 test([1, 2, 3], 0, 1); 40 test([1, 2, 3], 0, 1);
35 test([1, 2, 3], 0, 1, 99); 41 test([1, 2, 3], 0, 1, 99);
36 test([1, 2, 3], 1, 1); 42 test([1, 2, 3], 1, 1);
37 test([1, 2, 3], 1, 1, 499); 43 test([1, 2, 3], 1, 1, 499);
38 test([1, 2, 3], 3, 3); 44 test([1, 2, 3], 3, 3);
39 test([1, 2, 3], 3, 3, 499); 45 test([1, 2, 3], 3, 3, 499);
(...skipping 25 matching lines...) Expand all
65 expectUE(() => test(const [1, 2, 3], 1, 4)); 71 expectUE(() => test(const [1, 2, 3], 1, 4));
66 } 72 }
67 73
68 void expectRE(void f()) { 74 void expectRE(void f()) {
69 Expect.throws(f, (e) => e is RangeError); 75 Expect.throws(f, (e) => e is RangeError);
70 } 76 }
71 77
72 void expectUE(void f()) { 78 void expectUE(void f()) {
73 Expect.throws(f, (e) => e is UnsupportedError); 79 Expect.throws(f, (e) => e is UnsupportedError);
74 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698