| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 part of dart2js.semantics_visitor_test; | 5 part of dart2js.semantics_visitor_test; |
| 6 | 6 |
| 7 const Map<String, List<Test>> SEND_TESTS = const { | 7 const Map<String, List<Test>> SEND_TESTS = const { |
| 8 'Parameters': const [ | 8 'Parameters': const [ |
| 9 // Parameters | 9 // Parameters |
| 10 const Test('m(o) => o;', | 10 const Test('m(o) => o;', |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 ''' | 102 ''' |
| 103 class C { | 103 class C { |
| 104 static var o; | 104 static var o; |
| 105 } | 105 } |
| 106 ''', | 106 ''', |
| 107 'm() => p.C.o;', | 107 'm() => p.C.o;', |
| 108 const Visit(VisitKind.VISIT_STATIC_FIELD_GET, | 108 const Visit(VisitKind.VISIT_STATIC_FIELD_GET, |
| 109 element: 'field(C#o)')), | 109 element: 'field(C#o)')), |
| 110 const Test( | 110 const Test( |
| 111 ''' | 111 ''' |
| 112 class C { | |
| 113 var o; | |
| 114 } | |
| 115 m() => C.o; | |
| 116 ''', | |
| 117 const Visit(VisitKind.VISIT_UNRESOLVED_GET, | |
| 118 name: 'o')), | |
| 119 const Test( | |
| 120 ''' | |
| 121 class C { | |
| 122 C.o(); | |
| 123 } | |
| 124 m() => C.o; | |
| 125 ''', | |
| 126 const Visit(VisitKind.VISIT_UNRESOLVED_GET, | |
| 127 name: 'o')), | |
| 128 const Test( | |
| 129 ''' | |
| 130 class C {} | |
| 131 m() => C.this; | |
| 132 ''', | |
| 133 null), | |
| 134 const Test( | |
| 135 ''' | |
| 136 class C { static var o; } | 112 class C { static var o; } |
| 137 m() { C.o = 42; } | 113 m() { C.o = 42; } |
| 138 ''', | 114 ''', |
| 139 const Visit(VisitKind.VISIT_STATIC_FIELD_SET, | 115 const Visit(VisitKind.VISIT_STATIC_FIELD_SET, |
| 140 element: 'field(C#o)', | 116 element: 'field(C#o)', |
| 141 rhs: '42')), | 117 rhs: '42')), |
| 142 const Test.clazz( | 118 const Test.clazz( |
| 143 ''' | 119 ''' |
| 144 class C { | 120 class C { |
| 145 static var o; | 121 static var o; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 const Test.prefix( | 176 const Test.prefix( |
| 201 ''' | 177 ''' |
| 202 class C { | 178 class C { |
| 203 static var o; | 179 static var o; |
| 204 } | 180 } |
| 205 ''', | 181 ''', |
| 206 'm() { p.C.o(null, 42); }', | 182 'm() { p.C.o(null, 42); }', |
| 207 const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE, | 183 const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE, |
| 208 element: 'field(C#o)', | 184 element: 'field(C#o)', |
| 209 arguments: '(null,42)')), | 185 arguments: '(null,42)')), |
| 210 const Test( | |
| 211 ''' | |
| 212 class C {} | |
| 213 m() => C.this(null, 42); | |
| 214 ''', | |
| 215 const Visit(VisitKind.VISIT_UNRESOLVED_INVOKE, | |
| 216 name: 'this', arguments: '(null,42)')), | |
| 217 // TODO(johnniwinther): Expect [VISIT_FINAL_STATIC_FIELD_SET] instead. | 186 // TODO(johnniwinther): Expect [VISIT_FINAL_STATIC_FIELD_SET] instead. |
| 218 const Test( | 187 const Test( |
| 219 ''' | 188 ''' |
| 220 class C { static final o = 0; } | 189 class C { static final o = 0; } |
| 221 m() { C.o = 42; } | 190 m() { C.o = 42; } |
| 222 ''', | 191 ''', |
| 223 const Visit(VisitKind.VISIT_UNRESOLVED_SET, | 192 const Visit(VisitKind.VISIT_UNRESOLVED_SET, |
| 224 name: 'o', | 193 name: 'o', |
| 225 rhs: '42')), | 194 rhs: '42')), |
| 226 const Test.clazz( | 195 const Test.clazz( |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 const Test.prefix( | 331 const Test.prefix( |
| 363 ''' | 332 ''' |
| 364 class C { | 333 class C { |
| 365 static get o => 42; | 334 static get o => 42; |
| 366 } | 335 } |
| 367 ''', | 336 ''', |
| 368 'm() { p.C.o = 42; }', | 337 'm() { p.C.o = 42; }', |
| 369 const Visit(VisitKind.VISIT_UNRESOLVED_SET, | 338 const Visit(VisitKind.VISIT_UNRESOLVED_SET, |
| 370 name: 'o', | 339 name: 'o', |
| 371 rhs: '42')), | 340 rhs: '42')), |
| 341 // TODO(johnniwinther): Expected [VISIT_STATIC_SETTER_GET] instead. |
| 372 const Test( | 342 const Test( |
| 373 ''' | 343 ''' |
| 374 class C { | 344 class C { |
| 375 static set o(_) {} | 345 static set o(_) {} |
| 376 } | 346 } |
| 377 m() => C.o; | 347 m() => C.o; |
| 378 ''', | 348 ''', |
| 379 const Visit(VisitKind.VISIT_STATIC_SETTER_GET, | 349 const Visit(VisitKind.VISIT_UNRESOLVED_GET, |
| 380 element: 'setter(C#o)')), | 350 name: 'o')), |
| 381 const Test.clazz( | 351 const Test.clazz( |
| 382 ''' | 352 ''' |
| 383 class C { | 353 class C { |
| 384 static set o(_) {} | 354 static set o(_) {} |
| 385 m() => o; | 355 m() => o; |
| 386 } | 356 } |
| 387 ''', | 357 ''', |
| 388 const Visit(VisitKind.VISIT_STATIC_SETTER_GET, | 358 const Visit(VisitKind.VISIT_STATIC_SETTER_GET, |
| 389 element: 'setter(C#o)')), | 359 element: 'setter(C#o)')), |
| 390 | 360 |
| 391 const Test.clazz( | 361 const Test.clazz( |
| 392 ''' | 362 ''' |
| 393 class C { | 363 class C { |
| 394 static set o(_) {} | 364 static set o(_) {} |
| 395 m() => C.o; | 365 m() => C.o; |
| 396 } | 366 } |
| 397 ''', | 367 ''', |
| 398 const Visit(VisitKind.VISIT_STATIC_SETTER_GET, | 368 const Visit(VisitKind.VISIT_UNRESOLVED_GET, |
| 399 element: 'setter(C#o)')), | 369 name: 'o')), |
| 400 const Test.prefix( | 370 const Test.prefix( |
| 401 ''' | 371 ''' |
| 402 class C { | 372 class C { |
| 403 static set o(_) {} | 373 static set o(_) {} |
| 404 } | 374 } |
| 405 ''', | 375 ''', |
| 406 'm() => p.C.o;', | 376 'm() => p.C.o;', |
| 407 const Visit(VisitKind.VISIT_STATIC_SETTER_GET, | 377 const Visit(VisitKind.VISIT_UNRESOLVED_GET, |
| 408 element: 'setter(C#o)')), | 378 name: 'o')), |
| 409 const Test( | 379 const Test( |
| 410 ''' | 380 ''' |
| 411 class C { static set o(_) {} } | 381 class C { static set o(_) {} } |
| 412 m() { C.o = 42; } | 382 m() { C.o = 42; } |
| 413 ''', | 383 ''', |
| 414 const Visit(VisitKind.VISIT_STATIC_SETTER_SET, | 384 const Visit(VisitKind.VISIT_STATIC_SETTER_SET, |
| 415 element: 'setter(C#o)', | 385 element: 'setter(C#o)', |
| 416 rhs: '42')), | 386 rhs: '42')), |
| 417 const Test.clazz( | 387 const Test.clazz( |
| 418 ''' | 388 ''' |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 const Test.prefix( | 445 const Test.prefix( |
| 476 ''' | 446 ''' |
| 477 class C { | 447 class C { |
| 478 static get o => null; | 448 static get o => null; |
| 479 } | 449 } |
| 480 ''', | 450 ''', |
| 481 'm() { p.C.o(null, 42); }', | 451 'm() { p.C.o(null, 42); }', |
| 482 const Visit(VisitKind.VISIT_STATIC_GETTER_INVOKE, | 452 const Visit(VisitKind.VISIT_STATIC_GETTER_INVOKE, |
| 483 element: 'getter(C#o)', | 453 element: 'getter(C#o)', |
| 484 arguments: '(null,42)')), | 454 arguments: '(null,42)')), |
| 455 // TODO(johnniwinther): Expect [VISIT_STATIC_SETTER_INVOKE] instead. |
| 485 const Test( | 456 const Test( |
| 486 ''' | 457 ''' |
| 487 class C { static set o(_) {} } | 458 class C { static set o(_) {} } |
| 488 m() => C.o(null, 42); | 459 m() => C.o(null, 42); |
| 489 ''', | 460 ''', |
| 490 const Visit(VisitKind.VISIT_STATIC_SETTER_INVOKE, | 461 const Visit(VisitKind.VISIT_UNRESOLVED_INVOKE, |
| 491 element: 'setter(C#o)', | 462 name: 'o', |
| 492 arguments: '(null,42)')), | 463 arguments: '(null,42)')), |
| 493 const Test.clazz( | 464 const Test.clazz( |
| 494 ''' | 465 ''' |
| 495 class C { | 466 class C { |
| 496 static set o(_) {} | 467 static set o(_) {} |
| 497 m() { o(null, 42); } | 468 m() { o(null, 42); } |
| 498 } | 469 } |
| 499 ''', | 470 ''', |
| 500 const Visit(VisitKind.VISIT_STATIC_SETTER_INVOKE, | 471 const Visit(VisitKind.VISIT_STATIC_SETTER_INVOKE, |
| 501 element: 'setter(C#o)', | 472 element: 'setter(C#o)', |
| 502 arguments: '(null,42)')), | 473 arguments: '(null,42)')), |
| 503 const Test.clazz( | 474 const Test.clazz( |
| 504 ''' | 475 ''' |
| 505 class C { | 476 class C { |
| 506 static set o(_) {} | 477 static set o(_) {} |
| 507 m() { C.o(null, 42); } | 478 m() { C.o(null, 42); } |
| 508 } | 479 } |
| 509 ''', | 480 ''', |
| 510 const Visit(VisitKind.VISIT_STATIC_SETTER_INVOKE, | 481 const Visit(VisitKind.VISIT_UNRESOLVED_INVOKE, |
| 511 element: 'setter(C#o)', | 482 name: 'o', |
| 512 arguments: '(null,42)')), | 483 arguments: '(null,42)')), |
| 513 const Test.prefix( | 484 const Test.prefix( |
| 514 ''' | 485 ''' |
| 515 class C { | 486 class C { |
| 516 static set o(_) {} | 487 static set o(_) {} |
| 517 } | 488 } |
| 518 ''', | 489 ''', |
| 519 'm() { p.C.o(null, 42); }', | 490 'm() { p.C.o(null, 42); }', |
| 520 const Visit(VisitKind.VISIT_STATIC_SETTER_INVOKE, | 491 const Visit(VisitKind.VISIT_UNRESOLVED_INVOKE, |
| 521 element: 'setter(C#o)', | 492 name: 'o', |
| 522 arguments: '(null,42)')), | 493 arguments: '(null,42)')), |
| 523 ], | 494 ], |
| 524 'Static functions': const [ | 495 'Static functions': const [ |
| 525 // Static functions | 496 // Static functions |
| 526 const Test( | 497 const Test( |
| 527 ''' | 498 ''' |
| 528 class C { static o(a, b) {} } | 499 class C { static o(a, b) {} } |
| 529 m() => C.o; | 500 m() => C.o; |
| 530 ''', | 501 ''', |
| 531 const Visit(VisitKind.VISIT_STATIC_FUNCTION_GET, | 502 const Visit(VisitKind.VISIT_STATIC_FUNCTION_GET, |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 ''' | 1236 ''' |
| 1266 class C {} | 1237 class C {} |
| 1267 m() => C--; | 1238 m() => C--; |
| 1268 ''', | 1239 ''', |
| 1269 const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_POSTFIX, | 1240 const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_POSTFIX, |
| 1270 constant: 'C', | 1241 constant: 'C', |
| 1271 operator: '--')), | 1242 operator: '--')), |
| 1272 const Test( | 1243 const Test( |
| 1273 ''' | 1244 ''' |
| 1274 class C {} | 1245 class C {} |
| 1275 m() => (C).hashCode; | 1246 m() => C; |
| 1276 ''', | 1247 ''', |
| 1277 const [ | 1248 const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_GET, |
| 1278 const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_GET, | 1249 constant: 'C')), |
| 1279 receiver: '(C)', name: 'hashCode'), | |
| 1280 const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_GET, | |
| 1281 constant: 'C'), | |
| 1282 ]), | |
| 1283 ], | 1250 ], |
| 1284 'Typedef type literals': const [ | 1251 'Typedef type literals': const [ |
| 1285 // Typedef type literals | 1252 // Typedef type literals |
| 1286 const Test( | 1253 const Test( |
| 1287 ''' | 1254 ''' |
| 1288 typedef F(); | 1255 typedef F(); |
| 1289 m() => F; | 1256 m() => F; |
| 1290 ''', | 1257 ''', |
| 1291 const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_GET, | 1258 const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_GET, |
| 1292 constant: 'F')), | 1259 constant: 'F')), |
| (...skipping 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3445 const Visit( | 3412 const Visit( |
| 3446 VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_GET, | 3413 VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_GET, |
| 3447 receiver: 'a', | 3414 receiver: 'a', |
| 3448 name: 'b'), | 3415 name: 'b'), |
| 3449 const Visit( | 3416 const Visit( |
| 3450 VisitKind.VISIT_PARAMETER_GET, | 3417 VisitKind.VISIT_PARAMETER_GET, |
| 3451 element: 'parameter(m#a)'), | 3418 element: 'parameter(m#a)'), |
| 3452 ]), | 3419 ]), |
| 3453 const Test( | 3420 const Test( |
| 3454 ''' | 3421 ''' |
| 3455 class C { | |
| 3456 static var b; | |
| 3457 } | |
| 3458 m(a) => C?.b; | |
| 3459 ''', | |
| 3460 const [ | |
| 3461 const Visit( | |
| 3462 VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_GET, | |
| 3463 receiver: 'C', | |
| 3464 name: 'b'), | |
| 3465 const Visit( | |
| 3466 VisitKind.VISIT_CLASS_TYPE_LITERAL_GET, | |
| 3467 constant: 'C'), | |
| 3468 ]), | |
| 3469 const Test( | |
| 3470 ''' | |
| 3471 m(a) => a?.b = 42; | 3422 m(a) => a?.b = 42; |
| 3472 ''', | 3423 ''', |
| 3473 const [ | 3424 const [ |
| 3474 const Visit( | 3425 const Visit( |
| 3475 VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET, | 3426 VisitKind.VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_SET, |
| 3476 receiver: 'a', | 3427 receiver: 'a', |
| 3477 name: 'b', | 3428 name: 'b', |
| 3478 rhs: '42'), | 3429 rhs: '42'), |
| 3479 const Visit( | 3430 const Visit( |
| 3480 VisitKind.VISIT_PARAMETER_GET, | 3431 VisitKind.VISIT_PARAMETER_GET, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3558 ''' | 3509 ''' |
| 3559 m(a) => a ??= 42; | 3510 m(a) => a ??= 42; |
| 3560 ''', | 3511 ''', |
| 3561 const Visit( | 3512 const Visit( |
| 3562 VisitKind.VISIT_PARAMETER_COMPOUND, | 3513 VisitKind.VISIT_PARAMETER_COMPOUND, |
| 3563 element: 'parameter(m#a)', | 3514 element: 'parameter(m#a)', |
| 3564 operator: '??=', | 3515 operator: '??=', |
| 3565 rhs: '42')), | 3516 rhs: '42')), |
| 3566 ], | 3517 ], |
| 3567 }; | 3518 }; |
| OLD | NEW |