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

Side by Side Diff: tests/language/covariant_test.dart

Issue 2763823002: Move spaces from before comments to within comments (Closed)
Patch Set: Fix comments Created 3 years, 9 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 // Test that `covariant` can be parsed (and ignored) by 5 // Test that `covariant` can be parsed (and ignored) by
6 // dart2js and the VM. 6 // dart2js and the VM.
7 // This test only checks for non-strong mode behavior. 7 // This test only checks for non-strong mode behavior.
8 // 8 //
9 // Generally, `covariant` should be ignored, when it is used in the right 9 // Generally, `covariant` should be ignored, when it is used in the right
10 // places. 10 // places.
11 11
12 import 'package:expect/expect.dart'; 12 import 'package:expect/expect.dart';
13 13
14 // Top level field may not have a covariant. 14 // Top level field may not have a covariant.
15 // Would be considered a minor (acceptable) bug, if it was accepted here too. 15 // Would be considered a minor (acceptable) bug, if it was accepted here too.
16 covariant /// 00: compile-time error 16 covariant // /// 00: compile-time error
17 int x0; 17 int x0;
18 18
19 covariant int covariant; /// 00b: compile-time error 19 covariant int covariant; // /// 00b: compile-time error
20 20
21 int covariant; /// 00c: ok 21 int covariant; // /// 00c: ok
22 22
23 // Getters may never have `covariant`. (Neither on the top-level nor as members) 23 // Getters may never have `covariant`. (Neither on the top-level nor as members)
24 covariant /// 01: compile-time error 24 covariant // /// 01: compile-time error
25 int get x1 => 499; 25 int get x1 => 499;
26 26
27 // Top level setters may not have a covariant. 27 // Top level setters may not have a covariant.
28 // Would be considered a minor (acceptable) bug, if it was accepted here too. 28 // Would be considered a minor (acceptable) bug, if it was accepted here too.
29 void set x2( 29 void set x2(
30 covariant /// 02: compile-time error 30 covariant /// 02: compile-time error
31 int val) {} 31 int val) {}
32 32
33 // Same as above, but with `covariant` in different positions. 33 // Same as above, but with `covariant` in different positions.
34 // The `covariant` is just wrong there. 34 // The `covariant` is just wrong there.
35 35
36 int 36 int
37 covariant /// 03: compile-time error 37 covariant // /// 03: compile-time error
38 x3; 38 x3;
39 39
40 int 40 int
41 covariant /// 04: compile-time error 41 covariant // /// 04: compile-time error
42 get x4 => 499; 42 get x4 => 499;
43 43
44 void set x5( 44 void set x5(
45 int 45 int
46 covariant /// 05: compile-time error 46 covariant /// 05: compile-time error
47 val) {} 47 val) {}
48 48
49 49
50 // Same without types. 50 // Same without types.
51 51
52 // Since `covariant` is a built-in identifier, it is not allowed here. 52 // Since `covariant` is a built-in identifier, it is not allowed here.
53 covariant x6; /// 06: compile-time error 53 covariant x6; // /// 06: compile-time error
54 54
55 covariant covariant; /// 06b: compile-time error 55 covariant covariant; // /// 06b: compile-time error
56 56
57 // Getters may never have `covariant`. 57 // Getters may never have `covariant`.
58 covariant /// 07: compile-time error 58 covariant // /// 07: compile-time error
59 get x7 => 499; 59 get x7 => 499;
60 60
61 // Top level setters may not have a covariant. 61 // Top level setters may not have a covariant.
62 // Would be considered a minor (acceptable) bug, if it was accepted here too. 62 // Would be considered a minor (acceptable) bug, if it was accepted here too.
63 void set x8( 63 void set x8(
64 covariant /// 08: compile-time error 64 covariant /// 08: compile-time error
65 val) {} 65 val) {}
66 66
67 // If there is no type, then `covariant` is simply the parameter name: 67 // If there is no type, then `covariant` is simply the parameter name:
68 void set x9(covariant) {} 68 void set x9(covariant) {}
69 69
70 // Covariant won't work on return types. 70 // Covariant won't work on return types.
71 covariant /// 10: compile-time error 71 covariant // /// 10: compile-time error
72 int f10() => 499; 72 int f10() => 499;
73 73
74 // Covariant won't work as a return type. 74 // Covariant won't work as a return type.
75 covariant /// 11: compile-time error 75 covariant // /// 11: compile-time error
76 f11() => 499; 76 f11() => 499;
77 77
78 // Covariant should not work on top-level methods. 78 // Covariant should not work on top-level methods.
79 // It's a minor (acceptable) bug to not error out here. 79 // It's a minor (acceptable) bug to not error out here.
80 int f12( 80 int f12(
81 covariant /// 12: compile-time error 81 covariant /// 12: compile-time error
82 int x) => 499; 82 int x) => 499;
83 83
84 // `Covariant` must be in front of the types. 84 // `Covariant` must be in front of the types.
85 int f13( 85 int f13(
(...skipping 25 matching lines...) Expand all
111 // `Covariant` must be in front of modifiers. 111 // `Covariant` must be in front of modifiers.
112 int f17( 112 int f17(
113 final 113 final
114 covariant /// 17: compile-time error 114 covariant /// 17: compile-time error
115 int 115 int
116 x) => 499; 116 x) => 499;
117 117
118 // On its own, `covariant` is just a parameter name. 118 // On its own, `covariant` is just a parameter name.
119 int f18(covariant) => covariant; 119 int f18(covariant) => covariant;
120 120
121 covariant; /// 19: compile-time error 121 covariant; // /// 19: compile-time error
122 122
123 // All of the above as statics in a class. 123 // All of the above as statics in a class.
124 class A { 124 class A {
125 // Static fields may not have a covariant. 125 // Static fields may not have a covariant.
126 // Would be considered a minor (acceptable) bug, if it was accepted here too. 126 // Would be considered a minor (acceptable) bug, if it was accepted here too.
127 static 127 static
128 covariant /// 20: compile-time error 128 covariant // /// 20: compile-time error
129 int x20; 129 int x20;
130 130
131 static covariant int covariant /// 20b: compile-time error 131 static covariant int covariant // /// 20b: compile-time error
132 132
133 static int covariant; /// 20c: ok 133 static int covariant; // /// 20c: ok
134 134
135 // Getters may never have `covariant`. 135 // Getters may never have `covariant`.
136 static 136 static
137 covariant /// 21: compile-time error 137 covariant // /// 21: compile-time error
138 int get x21 => 499; 138 int get x21 => 499;
139 139
140 // Getters may never have `covariant`. 140 // Getters may never have `covariant`.
141 covariant /// 21b: compile-time error 141 covariant // /// 21b: compile-time error
142 static 142 static
143 int get x21b => 499; 143 int get x21b => 499;
144 144
145 // Static setters may not have a covariant. 145 // Static setters may not have a covariant.
146 // Would be considered a minor (acceptable) bug, if it was accepted here too. 146 // Would be considered a minor (acceptable) bug, if it was accepted here too.
147 static void set x22( 147 static void set x22(
148 covariant /// 22: compile-time error 148 covariant /// 22: compile-time error
149 int val) {} 149 int val) {}
150 150
151 // Same as above, but with `covariant` in different positions. 151 // Same as above, but with `covariant` in different positions.
152 // The `covariant` is just wrong there. 152 // The `covariant` is just wrong there.
153 153
154 static int 154 static int
155 covariant /// 23: compile-time error 155 covariant // /// 23: compile-time error
156 x23; 156 x23;
157 157
158 static int 158 static int
159 covariant /// 24: compile-time error 159 covariant // /// 24: compile-time error
160 get x24 => 499; 160 get x24 => 499;
161 161
162 static void set x25( 162 static void set x25(
163 int 163 int
164 covariant /// 25: compile-time error 164 covariant /// 25: compile-time error
165 val) {} 165 val) {}
166 166
167 // Since `covariant` is a built-in identifier, it is not allowed here. 167 // Since `covariant` is a built-in identifier, it is not allowed here.
168 static covariant x26; /// 26: compile-time error 168 static covariant x26; /// 26: compile-time error
169 static covariant covariant; /// 26b: compile-time error 169 static covariant covariant; /// 26b: compile-time error
170 170
171 // Getters may never have `covariant`. 171 // Getters may never have `covariant`.
172 static 172 static
173 covariant /// 27: compile-time error 173 covariant // /// 27: compile-time error
174 get x27 => 499; 174 get x27 => 499;
175 175
176 covariant /// 27b: compile-time error 176 covariant // /// 27b: compile-time error
177 static 177 static
178 get x27b => 499; 178 get x27b => 499;
179 179
180 // Static setters may not have a covariant. 180 // Static setters may not have a covariant.
181 // Would be considered a minor (acceptable) bug, if it was accepted here too. 181 // Would be considered a minor (acceptable) bug, if it was accepted here too.
182 static void set x28( 182 static void set x28(
183 covariant /// 28: compile-time error 183 covariant /// 28: compile-time error
184 val) {} 184 val) {}
185 185
186 // If there is no type, then `covariant` is simply the parameter name: 186 // If there is no type, then `covariant` is simply the parameter name:
187 static void set x29(covariant) {} 187 static void set x29(covariant) {}
188 188
189 // Covariant won't work on return types. 189 // Covariant won't work on return types.
190 static 190 static
191 covariant /// 30: compile-time error 191 covariant // /// 30: compile-time error
192 int f30() => 499; 192 int f30() => 499;
193 193
194 covariant /// 30b: compile-time error 194 covariant // /// 30b: compile-time error
195 static 195 static
196 int f30b() => 499; 196 int f30b() => 499;
197 197
198 // Covariant won't work as a return type. 198 // Covariant won't work as a return type.
199 static 199 static
200 covariant /// 31: compile-time error 200 covariant // /// 31: compile-time error
201 f31() => 499; 201 f31() => 499;
202 202
203 covariant /// 31b: compile-time error 203 covariant // /// 31b: compile-time error
204 static 204 static
205 f31b() => 499; 205 f31b() => 499;
206 206
207 // Covariant should not work on static methods. 207 // Covariant should not work on static methods.
208 // It's a minor (acceptable) bug to not error out here. 208 // It's a minor (acceptable) bug to not error out here.
209 static int f32( 209 static int f32(
210 covariant /// 32: compile-time error 210 covariant /// 32: compile-time error
211 int x) => 499; 211 int x) => 499;
212 212
213 // `Covariant` must be in front of the types. 213 // `Covariant` must be in front of the types.
(...skipping 26 matching lines...) Expand all
240 // `Covariant` must be in front of modifiers. 240 // `Covariant` must be in front of modifiers.
241 static int f37( 241 static int f37(
242 final 242 final
243 covariant /// 37: compile-time error 243 covariant /// 37: compile-time error
244 int 244 int
245 x) => 499; 245 x) => 499;
246 246
247 // `Covariant` on its own is just a parameter name. 247 // `Covariant` on its own is just a parameter name.
248 static int f38(covariant) => covariant; 248 static int f38(covariant) => covariant;
249 249
250 static covariant; /// 39: compile-time error 250 static covariant; // /// 39: compile-time error
251 251
252 } 252 }
253 253
254 // All of the above as instance members in a class. 254 // All of the above as instance members in a class.
255 class B { 255 class B {
256 covariant /// 40: ok 256 covariant // /// 40: ok
257 int x40; 257 int x40;
258 258
259 covariant int covariant; /// 40b: ok 259 covariant int covariant; // /// 40b: ok
260 260
261 int covariant; /// 40c: ok 261 int covariant; // /// 40c: ok
262 262
263 // Getters may never have `covariant`. 263 // Getters may never have `covariant`.
264 covariant /// 41: compile-time error 264 covariant // /// 41: compile-time error
265 int get x41 => 499; 265 int get x41 => 499;
266 266
267 void set x42( 267 void set x42(
268 covariant /// 42: ok 268 covariant // /// 42: ok
269 int val) {} 269 int val) {}
270 270
271 // `covariant` in the wrong position. 271 // `covariant` in the wrong position.
272 int 272 int
273 covariant /// 43: compile-time error 273 covariant // /// 43: compile-time error
274 x43; 274 x43;
275 275
276 // `covariant` in the wrong position. 276 // `covariant` in the wrong position.
277 int 277 int
278 covariant /// 44: compile-time error 278 covariant // /// 44: compile-time error
279 get x44 => 499; 279 get x44 => 499;
280 280
281 void set x45( 281 void set x45(
282 int 282 int
283 covariant /// 45: compile-time error 283 covariant /// 45: compile-time error
284 val) {} 284 val) {}
285 285
286 // Since `covariant` is a built-in identifier, it is not allowed here. 286 // Since `covariant` is a built-in identifier, it is not allowed here.
287 covariant x46; /// 46: compile-time error 287 covariant x46; /// 46: compile-time error
288 covariant covariant; /// 46b: compile-time error 288 covariant covariant; /// 46b: compile-time error
289 289
290 // Getters may never have `covariant`. 290 // Getters may never have `covariant`.
291 covariant /// 47: compile-time error 291 covariant // /// 47: compile-time error
292 get x47 => 499; 292 get x47 => 499;
293 293
294 void set x48( 294 void set x48(
295 covariant /// 48: ok 295 covariant // /// 48: ok
296 val) {} 296 val) {}
297 297
298 // If there is no type, then `covariant` is simply the parameter name: 298 // If there is no type, then `covariant` is simply the parameter name:
299 void set x49(covariant) {} 299 void set x49(covariant) {}
300 300
301 // Covariant won't work on return types. 301 // Covariant won't work on return types.
302 covariant /// 50: compile-time error 302 covariant // /// 50: compile-time error
303 int f50() => 499; 303 int f50() => 499;
304 304
305 // Covariant won't work as a return type. 305 // Covariant won't work as a return type.
306 covariant /// 51: compile-time error 306 covariant // /// 51: compile-time error
307 f51() => 499; 307 f51() => 499;
308 308
309 int f52( 309 int f52(
310 covariant /// 52: ok 310 covariant // /// 52: ok
311 int x) => 499; 311 int x) => 499;
312 312
313 // `Covariant` must be in front of the types. 313 // `Covariant` must be in front of the types.
314 int f53( 314 int f53(
315 int 315 int
316 covariant /// 53: compile-time error 316 covariant /// 53: compile-time error
317 x) => 499; 317 x) => 499;
318 318
319 int f54( 319 int f54(
320 covariant /// 54: ok 320 covariant // /// 54: ok
321 final x) => 499; 321 final x) => 499;
322 322
323 // `Covariant` must be in front of modifiers. 323 // `Covariant` must be in front of modifiers.
324 int f55( 324 int f55(
325 final 325 final
326 covariant /// 55: compile-time error 326 covariant /// 55: compile-time error
327 x) => 499; 327 x) => 499;
328 328
329 int f56( 329 int f56(
330 covariant /// 56: ok 330 covariant // /// 56: ok
331 final int x) => 499; 331 final int x) => 499;
332 332
333 // `Covariant` must be in front of modifiers. 333 // `Covariant` must be in front of modifiers.
334 int f57( 334 int f57(
335 final 335 final
336 covariant /// 57: compile-time error 336 covariant /// 57: compile-time error
337 int 337 int
338 x) => 499; 338 x) => 499;
339 339
340 // `Covariant` on its own is just a parameter name. 340 // `Covariant` on its own is just a parameter name.
341 int f58(covariant) => covariant; 341 int f58(covariant) => covariant;
342 342
343 covariant; /// 59: compile-time error 343 covariant; // /// 59: compile-time error
344 } 344 }
345 345
346 void use(x) {} 346 void use(x) {}
347 347
348 main() { 348 main() {
349 x0 = 0; 349 x0 = 0;
350 covariant = 0; /// 00b: continued 350 covariant = 0; // /// 00b: continued
351 covariant = 0; /// 00c: continued 351 covariant = 0; // /// 00c: continued
352 use(x1); 352 use(x1);
353 x2 = 499; 353 x2 = 499;
354 use(x3); 354 use(x3);
355 use(x4); 355 use(x4);
356 x5 = 42; 356 x5 = 42;
357 x6 = 0; /// 06: continued 357 x6 = 0; /// 06: continued
358 covariant = 0; /// 06b: continued 358 covariant = 0; /// 06b: continued
359 use(x7); 359 use(x7);
360 x8 = 11; 360 x8 = 11;
361 x9 = 12; 361 x9 = 12;
362 use(f10()); 362 use(f10());
363 use(f11()); 363 use(f11());
364 use(f12(2)); 364 use(f12(2));
365 use(f13(3)); 365 use(f13(3));
366 use(f14(3)); 366 use(f14(3));
367 use(f15(3)); 367 use(f15(3));
368 use(f16(3)); 368 use(f16(3));
369 use(f17(3)); 369 use(f17(3));
370 Expect.equals(123, f18(123)); 370 Expect.equals(123, f18(123));
371 use(covariant); /// 19: continued 371 use(covariant); // /// 19: continued
372 372
373 A.x20 = 0; 373 A.x20 = 0;
374 A.covariant = 0; /// 20b: continued 374 A.covariant = 0; // /// 20b: continued
375 A.covariant = 0; /// 20c: continued 375 A.covariant = 0; // /// 20c: continued
376 use(A.x21); 376 use(A.x21);
377 use(A.x21b); 377 use(A.x21b);
378 A.x22 = 499; 378 A.x22 = 499;
379 use(A.x23); 379 use(A.x23);
380 use(A.x24); 380 use(A.x24);
381 A.x25 = 42; 381 A.x25 = 42;
382 A.x26 = 0; /// 26: continued 382 A.x26 = 0; /// 26: continued
383 A.covariant = 0; /// 26b: continued 383 A.covariant = 0; /// 26b: continued
384 use(A.x27); 384 use(A.x27);
385 use(A.x27b); 385 use(A.x27b);
386 A.x28 = 11; 386 A.x28 = 11;
387 A.x29 = 12; 387 A.x29 = 12;
388 use(A.f30()); 388 use(A.f30());
389 use(A.f31()); 389 use(A.f31());
390 use(A.f31b()); 390 use(A.f31b());
391 use(A.f32(2)); 391 use(A.f32(2));
392 use(A.f33(3)); 392 use(A.f33(3));
393 use(A.f34(3)); 393 use(A.f34(3));
394 use(A.f35(3)); 394 use(A.f35(3));
395 use(A.f36(3)); 395 use(A.f36(3));
396 use(A.f37(3)); 396 use(A.f37(3));
397 Expect.equals(1234, A.f38(1234)); 397 Expect.equals(1234, A.f38(1234));
398 use(A.covariant); /// 39: continued 398 use(A.covariant); // /// 39: continued
399 399
400 var b = new B(); 400 var b = new B();
401 b.x40 = 0; 401 b.x40 = 0;
402 b.covariant = 0; /// 40b: continued 402 b.covariant = 0; // /// 40b: continued
403 b.covariant = 0; /// 40c: continued 403 b.covariant = 0; // /// 40c: continued
404 use(b.x41); 404 use(b.x41);
405 b.x42 = 499; 405 b.x42 = 499;
406 use(b.x43); 406 use(b.x43);
407 use(b.x44); 407 use(b.x44);
408 b.x45 = 42; 408 b.x45 = 42;
409 b.x46 = 0; /// 46: continued 409 b.x46 = 0; /// 46: continued
410 b.covariant = 0; /// 46b: continued 410 b.covariant = 0; /// 46b: continued
411 use(b.x47); 411 use(b.x47);
412 b.x48 = 11; 412 b.x48 = 11;
413 b.x49 = 12; 413 b.x49 = 12;
414 use(b.f50()); 414 use(b.f50());
415 use(b.f51()); 415 use(b.f51());
416 use(b.f52(2)); 416 use(b.f52(2));
417 use(b.f53(2)); 417 use(b.f53(2));
418 use(b.f54(3)); 418 use(b.f54(3));
419 use(b.f55(3)); 419 use(b.f55(3));
420 use(b.f56(3)); 420 use(b.f56(3));
421 use(b.f57(3)); 421 use(b.f57(3));
422 Expect.equals(12345, b.f58(12345)); 422 Expect.equals(12345, b.f58(12345));
423 use(B.covariant); /// 59: continued 423 use(B.covariant); // /// 59: continued
424 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698