OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 // Dart test program for testing params. | 4 // Dart test program for testing params. |
5 | 5 |
6 // Convenience values. | 6 // Convenience values. |
7 var c = new C(); | 7 var c = new C(); |
8 var x = 42; | 8 var x = 42; |
9 var y = 42; | 9 var y = 42; |
10 var z = 42; | 10 var z = 42; |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 void set topsetx(x, ) {} /// none: continued | 35 void set topsetx(x, ) {} /// none: continued |
36 | 36 |
37 // After specific parameter formats. | 37 // After specific parameter formats. |
38 void afterDefaultValueY([int y = 42, ]) {} /// none: continued | 38 void afterDefaultValueY([int y = 42, ]) {} /// none: continued |
39 void afterDefaultValueZ({int z : 42, }) {} /// none: continued | 39 void afterDefaultValueZ({int z : 42, }) {} /// none: continued |
40 void afterFunsigX(void f(),) {} /// none: continued | 40 void afterFunsigX(void f(),) {} /// none: continued |
41 void afterFunsigY([void f(),]) {} /// none: continued | 41 void afterFunsigY([void f(),]) {} /// none: continued |
42 void afterFunsigZ({void f(),}) {} /// none: continued | 42 void afterFunsigZ({void f(),}) {} /// none: continued |
43 void afterFunsigDefaultValueY([void f() = topy,]) {} /// none: continued | 43 void afterFunsigDefaultValueY([void f() = topy,]) {} /// none: continued |
44 void afterFunsigDefaultValueZ({void f() : topt,}) {} /// none: continued | 44 void afterFunsigDefaultValueZ({void f() : topz,}) {} /// none: continued |
45 | 45 |
46 class C { | 46 class C { |
47 C(); | 47 C(); |
48 | 48 |
49 // Constructors. | 49 // Constructors. |
50 C.x(x, ); /// none: continued | 50 C.x(x, ); /// none: continued |
51 C.y([y, ]); /// none: continued | 51 C.y([y, ]); /// none: continued |
52 C.xy(x, [y, ]); /// none: continued | 52 C.xy(x, [y, ]); /// none: continued |
53 C.z({z, }); /// none: continued | 53 C.z({z, }); /// none: continued |
54 C.xz(x, {z, }); /// none: continued | 54 C.xz(x, {z, }); /// none: continued |
(...skipping 15 matching lines...) Expand all Loading... |
70 void instancexz(x, {z, }) {} /// none: continued | 70 void instancexz(x, {z, }) {} /// none: continued |
71 | 71 |
72 void set instancesetx(x, ) {} /// none: continued | 72 void set instancesetx(x, ) {} /// none: continued |
73 | 73 |
74 operator +(x, ) => this; /// none: continued | 74 operator +(x, ) => this; /// none: continued |
75 operator []=(x, y, ) {} /// none: continued | 75 operator []=(x, y, ) {} /// none: continued |
76 } | 76 } |
77 | 77 |
78 main() { | 78 main() { |
79 testCalls(); /// none: continued | 79 testCalls(); /// none: continued |
80 // Make sure the Bad class is checked. | 80 // Make sure the cases are checked. |
81 new Bad().method(); | 81 testBadCalls(); |
82 } | 82 } |
83 | 83 |
84 void testCalls() { | 84 void testCalls() { |
85 // Check that all functions can be called normally | 85 // Check that all functions can be called normally |
86 topx(x); /// none: continued | 86 topx(x); /// none: continued |
87 topy(y); /// none: continued | 87 topy(y); /// none: continued |
88 topxy(x, y); /// none: continued | 88 topxy(x, y); /// none: continued |
89 topz(); /// none: continued | 89 topz(); /// none: continued |
90 topz(z: z); /// none: continued | 90 topz(z: z); /// none: continued |
91 topxz(x); /// none: continued | 91 topxz(x); /// none: continued |
(...skipping 25 matching lines...) Expand all Loading... |
117 c.instancexy(x); /// none: continued | 117 c.instancexy(x); /// none: continued |
118 c.instancexy(x, y); /// none: continued | 118 c.instancexy(x, y); /// none: continued |
119 c.instancez(); /// none: continued | 119 c.instancez(); /// none: continued |
120 c.instancez(z: z); /// none: continued | 120 c.instancez(z: z); /// none: continued |
121 c.instancexz(x); /// none: continued | 121 c.instancexz(x); /// none: continued |
122 c.instancexz(x, z: z); /// none: continued | 122 c.instancexz(x, z: z); /// none: continued |
123 c.instancesetx = x; /// none: continued | 123 c.instancesetx = x; /// none: continued |
124 c + x; /// none: continued | 124 c + x; /// none: continued |
125 c[x] = y; /// none: continued | 125 c[x] = y; /// none: continued |
126 | 126 |
127 // Call with ekstra comma (not possible for setters and operators). | 127 // Call with extra comma (not possible for setters and operators). |
128 topx(x, ); /// none: continued | 128 topx(x, ); /// none: continued |
129 topy(y, ); /// none: continued | 129 topy(y, ); /// none: continued |
130 topxy(x, y, ); /// none: continued | 130 topxy(x, y, ); /// none: continued |
131 topxy(x, ); /// none: continued | 131 topxy(x, ); /// none: continued |
132 topz(z: z, ); /// none: continued | 132 topz(z: z, ); /// none: continued |
133 topxz(x, ); /// none: continued | 133 topxz(x, ); /// none: continued |
134 topxz(x, z: z, ); /// none: continued | 134 topxz(x, z: z, ); /// none: continued |
135 new C.x(x, ); /// none: continued | 135 new C.x(x, ); /// none: continued |
136 new C.xy(x, y, ); /// none: continued | 136 new C.xy(x, y, ); /// none: continued |
137 new C.xy(x, ); /// none: continued | 137 new C.xy(x, ); /// none: continued |
(...skipping 24 matching lines...) Expand all Loading... |
162 if (topxz is! fxz) throw "Bad type: $fxz"; /// none: continued | 162 if (topxz is! fxz) throw "Bad type: $fxz"; /// none: continued |
163 | 163 |
164 // Parameter types work (checked mode only test). | 164 // Parameter types work (checked mode only test). |
165 argfx(topx); /// none: continued | 165 argfx(topx); /// none: continued |
166 argfy(topy); /// none: continued | 166 argfy(topy); /// none: continued |
167 argfxy(topxy); /// none: continued | 167 argfxy(topxy); /// none: continued |
168 argfz(topz); /// none: continued | 168 argfz(topz); /// none: continued |
169 argfxz(topxz); /// none: continued | 169 argfxz(topxz); /// none: continued |
170 } | 170 } |
171 | 171 |
172 | |
173 // Invalid syntax. This was invalid syntax before the addition of trailing | 172 // Invalid syntax. This was invalid syntax before the addition of trailing |
174 // commas too, and should stay that way. | 173 // commas too, and should stay that way. |
175 void topBadEmpty(,) {} /// 1: compile-time error | 174 void topBadEmpty(,) {} /// 1: compile-time error |
176 void topBadStart(, a) {} /// 2: compile-time error | 175 void topBadStart(, a) {} /// 2: compile-time error |
177 void topBadEnd(a,,) {} /// 3: compile-time error | 176 void topBadEnd(a,,) {} /// 3: compile-time error |
178 void topBadMiddle(a,, b) {} /// 4: compile-time error | 177 void topBadMiddle(a,, b) {} /// 4: compile-time error |
179 void topBadPosEmpty([]) {} /// 5: compile-time error | 178 void topBadPosEmpty([]) {} /// 5: compile-time error |
180 void topBadPosEmpty(,[]) {} /// 6: compile-time error | 179 void topBadPosEmpty(,[]) {} /// 6: compile-time error |
181 void topBadPosEmpty([,]) {} /// 7: compile-time error | 180 void topBadPosEmpty([,]) {} /// 7: compile-time error |
182 void topBadPosEmpty([],) {} /// 8: compile-time error | 181 void topBadPosEmpty([],) {} /// 8: compile-time error |
183 void topBadPosStart(,[a]) {} /// 9: compile-time error | 182 void topBadPosStart(,[a]) {} /// 9: compile-time error |
184 void topBadPosStart([, a]) {} /// 10: compile-time error | 183 void topBadPosStart([, a]) {} /// 10: compile-time error |
185 void topBadPosEnd([a,,]) {} /// 11: compile-time error | 184 void topBadPosEnd([a,,]) {} /// 11: compile-time error |
186 void topBadPosStart([a],) {} /// 12: compile-time error | 185 void topBadPosStart([a],) {} /// 12: compile-time error |
187 void topBadPosMiddle([a,, b]) {} /// 13: compile-time error | 186 void topBadPosMiddle([a,, b]) {} /// 13: compile-time error |
188 void topBadNamEmpty({}) {} /// 14: compile-time error | 187 void topBadNamEmpty({}) {} /// 14: compile-time error |
189 void topBadNamEmpty(,{}) {} /// 15: compile-time error | 188 void topBadNamEmpty(,{}) {} /// 15: compile-time error |
190 void topBadNamEmpty({,}) {} /// 16: compile-time error | 189 void topBadNamEmpty({,}) {} /// 16: compile-time error |
191 void topBadNamEmpty({},) {} /// 17: compile-time error | 190 void topBadNamEmpty({},) {} /// 17: compile-time error |
192 void topBadNamStart(,{a}) {} /// 18: compile-time error | 191 void topBadNamStart(,{a}) {} /// 18: compile-time error |
193 void topBadNamStart({, a}) {} /// 19: compile-time error | 192 void topBadNamStart({, a}) {} /// 19: compile-time error |
194 void topBadNamEnd({a,,}) {} /// 20: compile-time error | 193 void topBadNamEnd({a,,}) {} /// 20: compile-time error |
195 void topBadNamStart({a},) {} /// 21: compile-time error | 194 void topBadNamStart({a},) {} /// 21: compile-time error |
196 void topBadNamMiddle({a,, b}) {} /// 22: compile-time error | 195 void topBadNamMiddle({a,, b}) {} /// 22: compile-time error |
197 void set topSetBadEmpty(,) {} /// 23: compile-time error | 196 void set topSetBadEmpty(,) {} /// 23: compile-time error |
198 void set topSetBadStart(, a) {} /// 24: compile-time error | 197 void set topSetBadStart(, a) {} /// 24: compile-time error |
199 void set topSetBadEnd(a,,) {} /// 25: compile-time error | 198 void set topSetBadEnd(a,,) {} /// 25: compile-time error |
200 void set topSetBadMiddle(a,, b) {} /// 26: compile-time error | 199 void set topSetBadMiddle(a,, b) {} /// 26: compile-time error |
201 class Bad { | 200 class Bad { |
| 201 Bad() {} |
202 Bad.empty(,) {} /// 27: compile-time error | 202 Bad.empty(,) {} /// 27: compile-time error |
203 Bad.start(, a) {} /// 28: compile-time error | 203 Bad.start(, a) {} /// 28: compile-time error |
204 Bad.end(a,,) {} /// 29: compile-time error | 204 Bad.end(a,,) {} /// 29: compile-time error |
205 Bad.middle(a,, b) {} /// 30: compile-time error | 205 Bad.middle(a,, b) {} /// 30: compile-time error |
206 Bad.posEmpty([]) {} /// 31: compile-time error | 206 Bad.posEmpty([]) {} /// 31: compile-time error |
207 Bad.posEmpty(,[]) {} /// 32: compile-time error | 207 Bad.posEmpty(,[]) {} /// 32: compile-time error |
208 Bad.posEmpty([,]) {} /// 33: compile-time error | 208 Bad.posEmpty([,]) {} /// 33: compile-time error |
209 Bad.posEmpty([],) {} /// 34: compile-time error | 209 Bad.posEmpty([],) {} /// 34: compile-time error |
210 Bad.posStart(,[a]) {} /// 35: compile-time error | 210 Bad.posStart(,[a]) {} /// 35: compile-time error |
211 Bad.posStart([, a]) {} /// 36: compile-time error | 211 Bad.posStart([, a]) {} /// 36: compile-time error |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 typedef void BadPosMiddle([a,, b]); /// 201: compile-time error | 392 typedef void BadPosMiddle([a,, b]); /// 201: compile-time error |
393 typedef void BadNamEmpty({}); /// 202: compile-time error | 393 typedef void BadNamEmpty({}); /// 202: compile-time error |
394 typedef void BadNamEmpty(,{}); /// 203: compile-time error | 394 typedef void BadNamEmpty(,{}); /// 203: compile-time error |
395 typedef void BadNamEmpty({,}); /// 204: compile-time error | 395 typedef void BadNamEmpty({,}); /// 204: compile-time error |
396 typedef void BadNamEmpty({},); /// 205: compile-time error | 396 typedef void BadNamEmpty({},); /// 205: compile-time error |
397 typedef void BadNamStart(,{a}); /// 206: compile-time error | 397 typedef void BadNamStart(,{a}); /// 206: compile-time error |
398 typedef void BadNamStart({, a}); /// 207: compile-time error | 398 typedef void BadNamStart({, a}); /// 207: compile-time error |
399 typedef void BadNamEnd({a,,}); /// 208: compile-time error | 399 typedef void BadNamEnd({a,,}); /// 208: compile-time error |
400 typedef void BadNamStart({a},); /// 209: compile-time error | 400 typedef void BadNamStart({a},); /// 209: compile-time error |
401 typedef void BadNamMiddle({a,, b}); /// 210: compile-time error | 401 typedef void BadNamMiddle({a,, b}); /// 210: compile-time error |
| 402 |
| 403 void testBadCalls() { |
| 404 topBadEmpty(); /// 1: continued |
| 405 topBadStart(); /// 2: continued |
| 406 topBadEnd(); /// 3: continued |
| 407 topBadMiddle(); /// 4: continued |
| 408 topBadPosEmpty(); /// 5: continued |
| 409 topBadPosEmpty(); /// 6: continued |
| 410 topBadPosEmpty(); /// 7: continued |
| 411 topBadPosEmpty(); /// 8: continued |
| 412 topBadPosStart(); /// 9: continued |
| 413 topBadPosStart(); /// 10: continued |
| 414 topBadPosEnd(); /// 11: continued |
| 415 topBadPosStart(); /// 12: continued |
| 416 topBadPosMiddle(); /// 13: continued |
| 417 topBadNamEmpty(); /// 14: continued |
| 418 topBadNamEmpty(); /// 15: continued |
| 419 topBadNamEmpty(); /// 16: continued |
| 420 topBadNamEmpty(); /// 17: continued |
| 421 topBadNamStart(); /// 18: continued |
| 422 topBadNamStart(); /// 19: continued |
| 423 topBadNamEnd(); /// 20: continued |
| 424 topBadNamStart(); /// 21: continued |
| 425 topBadNamMiddle(); /// 22: continued |
| 426 topSetBadEmpty = 1; /// 23: continued |
| 427 topSetBadStart = 1; /// 24: continued |
| 428 topSetBadEnd = 1; /// 25: continued |
| 429 topSetBadMiddle = 1; /// 26: continued |
| 430 new Bad.empty(); /// 27: continued |
| 431 new Bad.start(); /// 28: continued |
| 432 new Bad.end(); /// 29: continued |
| 433 new Bad.middle(); /// 30: continued |
| 434 new Bad.posEmpty(); /// 31: continued |
| 435 new Bad.posEmpty(); /// 32: continued |
| 436 new Bad.posEmpty(); /// 33: continued |
| 437 new Bad.posEmpty(); /// 34: continued |
| 438 new Bad.posStart(); /// 35: continued |
| 439 new Bad.posStart(); /// 36: continued |
| 440 new Bad.posEnd(); /// 37: continued |
| 441 new Bad.posStart(); /// 38: continued |
| 442 new Bad.PosMiddle(); /// 39: continued |
| 443 new Bad.namEmpty(); /// 40: continued |
| 444 new Bad.namEmpty(); /// 41: continued |
| 445 new Bad.namEmpty(); /// 42: continued |
| 446 new Bad.namEmpty(); /// 43: continued |
| 447 new Bad.namStart(); /// 44: continued |
| 448 new Bad.namStart(); /// 45: continued |
| 449 new Bad.namEnd(); /// 46: continued |
| 450 new Bad.namStart(); /// 47: continued |
| 451 new Bad.namMiddle(); /// 48: continued |
| 452 Bad.staticBadEmpty(); /// 49: continued |
| 453 Bad.staticBadStart(); /// 50: continued |
| 454 Bad.staticBadEnd(); /// 51: continued |
| 455 Bad.staticBadMiddle(); /// 52: continued |
| 456 Bad.staticBadPosEmpty(); /// 53: continued |
| 457 Bad.staticBadPosEmpty(); /// 54: continued |
| 458 Bad.staticBadPosEmpty(); /// 55: continued |
| 459 Bad.staticBadPosEmpty(); /// 56: continued |
| 460 Bad.staticBadPosStart(); /// 57: continued |
| 461 Bad.staticBadPosStart(); /// 58: continued |
| 462 Bad.staticBadPosEnd(); /// 59: continued |
| 463 Bad.staticBadPosStart(); /// 60: continued |
| 464 Bad.staticBadPosMiddle(); /// 61: continued |
| 465 Bad.staticBadNamEmpty(); /// 62: continued |
| 466 Bad.staticBadNamEmpty(); /// 63: continued |
| 467 Bad.staticBadNamEmpty(); /// 64: continued |
| 468 Bad.staticBadNamEmpty(); /// 65: continued |
| 469 Bad.staticBadNamStart(); /// 66: continued |
| 470 Bad.staticBadNamStart(); /// 67: continued |
| 471 Bad.staticBadNamEnd(); /// 68: continued |
| 472 Bad.staticBadNamStart(); /// 69: continued |
| 473 Bad.staticBadNamMiddle(); /// 70: continued |
| 474 Bad.staticSetBadEmpty = 1; /// 71: continued |
| 475 Bad.staticSetBadStart = 1; /// 72: continued |
| 476 Bad.staticSetBadEnd = 1; /// 73: continued |
| 477 Bad.staticSetBadMiddle = 1; /// 74: continued |
| 478 |
| 479 var bad = new Bad(); |
| 480 bad.instanceBadEmpty(); /// 75: continued |
| 481 bad.instanceBadStart(); /// 76: continued |
| 482 bad.instanceBadEnd(); /// 77: continued |
| 483 bad.instanceBadMiddle(); /// 78: continued |
| 484 bad.instanceBadPosEmpty(); /// 79: continued |
| 485 bad.instanceBadPosEmpty(); /// 80: continued |
| 486 bad.instanceBadPosEmpty(); /// 81: continued |
| 487 bad.instanceBadPosEmpty(); /// 82: continued |
| 488 bad.instanceBadPosStart(); /// 83: continued |
| 489 bad.instanceBadPosStart(); /// 84: continued |
| 490 bad.instanceBadPosEnd(); /// 85: continued |
| 491 bad.instanceBadPosStart(); /// 86: continued |
| 492 bad.instanceBadPosMiddle(); /// 87: continued |
| 493 bad.instanceBadNamEmpty(); /// 88: continued |
| 494 bad.instanceBadNamEmpty(); /// 89: continued |
| 495 bad.instanceBadNamEmpty(); /// 90: continued |
| 496 bad.instanceBadNamEmpty(); /// 91: continued |
| 497 bad.instanceBadNamStart(); /// 92: continued |
| 498 bad.instanceBadNamStart(); /// 93: continued |
| 499 bad.instanceBadNamEnd(); /// 94: continued |
| 500 bad.instanceBadNamStart(); /// 95: continued |
| 501 bad.instanceBadNamMiddle(); /// 96: continued |
| 502 bad.instanceSetBadEmpty = 1; /// 97: continued |
| 503 bad.instanceSetBadStart = 1; /// 98: continued |
| 504 bad.instanceSetBadEnd = 1; /// 99: continued |
| 505 bad.instanceSetBadMiddle = 1; /// 100: continued |
| 506 bad * bad; /// 101: continued |
| 507 bad * bad; /// 102: continued |
| 508 bad * bad; /// 103: continued |
| 509 bad[1] = 1; /// 104: continued |
| 510 bad[1] = 1; /// 105: continued |
| 511 bad[1] = 1; /// 106: continued |
| 512 bad[1] = 1; /// 107: continued |
| 513 |
| 514 // This covers tests 108-166 |
| 515 bad.method(); |
| 516 |
| 517 bad.f(() {}); /// 167: compile-time error |
| 518 bad.f(() {}); /// 168: compile-time error |
| 519 bad.f(() {}); /// 169: compile-time error |
| 520 bad.f(() {}); /// 170: compile-time error |
| 521 bad.f(() {}); /// 171: compile-time error |
| 522 bad.f(() {}); /// 172: compile-time error |
| 523 bad.f(() {}); /// 173: compile-time error |
| 524 bad.f(() {}); /// 174: compile-time error |
| 525 bad.f(() {}); /// 175: compile-time error |
| 526 bad.f(() {}); /// 176: compile-time error |
| 527 bad.f(() {}); /// 177: compile-time error |
| 528 bad.f(() {}); /// 178: compile-time error |
| 529 bad.f(() {}); /// 179: compile-time error |
| 530 bad.f(() {}); /// 180: compile-time error |
| 531 bad.f(() {}); /// 181: compile-time error |
| 532 bad.f(() {}); /// 182: compile-time error |
| 533 bad.f(() {}); /// 183: compile-time error |
| 534 bad.f(() {}); /// 184: compile-time error |
| 535 bad.f(() {}); /// 185: compile-time error |
| 536 bad.f(() {}); /// 186: compile-time error |
| 537 bad.f(() {}); /// 187: compile-time error |
| 538 bad.f(() {}); /// 188: compile-time error |
| 539 |
| 540 BadEmpty x; /// 189: compile-time error |
| 541 BadStart x; /// 190: compile-time error |
| 542 BadEnd x; /// 191: compile-time error |
| 543 BadMiddle x; /// 192: compile-time error |
| 544 BadPosEmpty x; /// 193: compile-time error |
| 545 BadPosEmpty x; /// 194: compile-time error |
| 546 BadPosEmpty x; /// 195: compile-time error |
| 547 BadPosEmpty x; /// 196: compile-time error |
| 548 BadPosStart x; /// 197: compile-time error |
| 549 BadPosStart x; /// 198: compile-time error |
| 550 BadPosEnd x; /// 199: compile-time error |
| 551 BadPosStart x; /// 200: compile-time error |
| 552 BadPosMiddle x; /// 201: compile-time error |
| 553 BadNamEmpty x; /// 202: compile-time error |
| 554 BadNamEmpty x; /// 203: compile-time error |
| 555 BadNamEmpty x; /// 204: compile-time error |
| 556 BadNamEmpty x; /// 205: compile-time error |
| 557 BadNamStart x; /// 206: compile-time error |
| 558 BadNamStart x; /// 207: compile-time error |
| 559 BadNamEnd x; /// 208: compile-time error |
| 560 BadNamStart x; /// 209: compile-time error |
| 561 BadNamMiddle x; /// 210: compile-time error |
| 562 } |
OLD | NEW |