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

Side by Side Diff: tests/corelib_strong/sort_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 // Dart test for sort routines. 5 // Dart test for sort routines.
6 library sort_test; 6 library sort_test;
7
7 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
8 import 'sort_helper.dart'; 9 import 'sort_helper.dart';
9 10
10 main() { 11 main() {
11 var compare = (a, b) => a.compareTo(b); 12 var compare = (a, b) => a.compareTo(b);
12 var sort = (list) => list.sort(compare); 13 var sort = (list) => list.sort(compare);
13 new SortHelper(sort, compare).run(); 14 new SortHelper(sort, compare).run();
14 15
15 compare = (a, b) => -a.compareTo(b); 16 compare = (a, b) => -a.compareTo(b);
16 new SortHelper(sort, compare).run(); 17 new SortHelper(sort, compare).run();
17 18
18 var intCompare = (int a, int b) => a.compareTo(b); 19 var intCompare = (int a, int b) => a.compareTo(b);
19 20
20 // Pivot-canditate indices: 7, 15, 22, 29, 37 21 // Pivot-canditate indices: 7, 15, 22, 29, 37
21 // Test dutch flag partitioning (canditates 2 and 4 are the same). 22 // Test dutch flag partitioning (canditates 2 and 4 are the same).
22 var list = [0, 0, 0, 0, 0, 0, 0, 0/**/, 0, 0, 0, 0, 0, 0, 0, 23 var list = [
23 1/**/, 1, 1, 1, 1, 1, 1, 1/**/, 1, 1, 1, 1, 1, 1, 1/**/, 24 0,
24 2, 2, 2, 2, 2, 2, 2, 2/**/, 2, 2, 2, 2, 2, 2, 2]; 25 0,
26 0,
27 0,
28 0,
29 0,
30 0,
31 0 /**/,
32 0,
33 0,
34 0,
35 0,
36 0,
37 0,
38 0,
39 1 /**/,
40 1,
41 1,
42 1,
43 1,
44 1,
45 1,
46 1 /**/,
47 1,
48 1,
49 1,
50 1,
51 1,
52 1,
53 1 /**/,
54 2,
55 2,
56 2,
57 2,
58 2,
59 2,
60 2,
61 2 /**/,
62 2,
63 2,
64 2,
65 2,
66 2,
67 2,
68 2
69 ];
25 list.sort(intCompare); 70 list.sort(intCompare);
26 Expect.listEquals(list, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71 Expect.listEquals(list, [
27 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 72 0,
28 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]); 73 0,
74 0,
75 0,
76 0,
77 0,
78 0,
79 0,
80 0,
81 0,
82 0,
83 0,
84 0,
85 0,
86 0,
87 1,
88 1,
89 1,
90 1,
91 1,
92 1,
93 1,
94 1,
95 1,
96 1,
97 1,
98 1,
99 1,
100 1,
101 1,
102 2,
103 2,
104 2,
105 2,
106 2,
107 2,
108 2,
109 2,
110 2,
111 2,
112 2,
113 2,
114 2,
115 2,
116 2
117 ]);
29 118
30 list = [0, 0, 0, 0, 0, 0, 0, 1/**/, 0, 0, 0, 0, 0, 0, 0, 119 list = [
31 0/**/, 1, 1, 1, 1, 1, 1, 0/**/, 1, 1, 1, 1, 1, 1, 0/**/, 120 0,
32 2/**/, 2, 2, 2, 2, 2, 2, 2/**/, 2, 2, 2, 2, 2, 2, 2]; 121 0,
122 0,
123 0,
124 0,
125 0,
126 0,
127 1 /**/,
128 0,
129 0,
130 0,
131 0,
132 0,
133 0,
134 0,
135 0 /**/,
136 1,
137 1,
138 1,
139 1,
140 1,
141 1,
142 0 /**/,
143 1,
144 1,
145 1,
146 1,
147 1,
148 1,
149 0 /**/,
150 2 /**/,
151 2,
152 2,
153 2,
154 2,
155 2,
156 2,
157 2 /**/,
158 2,
159 2,
160 2,
161 2,
162 2,
163 2,
164 2
165 ];
33 list.sort(intCompare); 166 list.sort(intCompare);
34 Expect.listEquals(list, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 167 Expect.listEquals(list, [
35 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 168 0,
36 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]); 169 0,
170 0,
171 0,
172 0,
173 0,
174 0,
175 0,
176 0,
177 0,
178 0,
179 0,
180 0,
181 0,
182 0,
183 0,
184 0,
185 1,
186 1,
187 1,
188 1,
189 1,
190 1,
191 1,
192 1,
193 1,
194 1,
195 1,
196 1,
197 1,
198 2,
199 2,
200 2,
201 2,
202 2,
203 2,
204 2,
205 2,
206 2,
207 2,
208 2,
209 2,
210 2,
211 2,
212 2
213 ]);
37 214
38 // Pivots: 1 and 8. 215 // Pivots: 1 and 8.
39 // The second partition will be big (more than 2/3 of the list), and an 216 // The second partition will be big (more than 2/3 of the list), and an
40 // optimization kicks in that removes the pivots from the partition. 217 // optimization kicks in that removes the pivots from the partition.
41 list = [0, 9, 0, 9, 3, 9, 0, 1/**/, 1, 0, 1, 9, 8, 2, 1, 218 list = [
42 1/**/, 4, 5, 2, 5, 0, 1, 8/**/, 8, 8, 5, 2, 2, 9, 8/**/, 219 0,
43 8, 4, 4, 1, 5, 3, 2, 8/**/, 5, 1, 2, 8, 5, 6, 8]; 220 9,
221 0,
222 9,
223 3,
224 9,
225 0,
226 1 /**/,
227 1,
228 0,
229 1,
230 9,
231 8,
232 2,
233 1,
234 1 /**/,
235 4,
236 5,
237 2,
238 5,
239 0,
240 1,
241 8 /**/,
242 8,
243 8,
244 5,
245 2,
246 2,
247 9,
248 8 /**/,
249 8,
250 4,
251 4,
252 1,
253 5,
254 3,
255 2,
256 8 /**/,
257 5,
258 1,
259 2,
260 8,
261 5,
262 6,
263 8
264 ];
44 list.sort(intCompare); 265 list.sort(intCompare);
45 Expect.listEquals(list, [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 266 Expect.listEquals(list, [
46 2, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 267 0,
47 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9]); 268 0,
269 0,
270 0,
271 0,
272 1,
273 1,
274 1,
275 1,
276 1,
277 1,
278 1,
279 1,
280 2,
281 2,
282 2,
283 2,
284 2,
285 2,
286 3,
287 3,
288 4,
289 4,
290 4,
291 5,
292 5,
293 5,
294 5,
295 5,
296 5,
297 6,
298 8,
299 8,
300 8,
301 8,
302 8,
303 8,
304 8,
305 8,
306 8,
307 9,
308 9,
309 9,
310 9,
311 9
312 ]);
48 } 313 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698