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;', |
11 const Visit(VisitKind.VISIT_PARAMETER_GET, | 11 const Visit(VisitKind.VISIT_PARAMETER_GET, |
12 element: 'parameter(m#o)')), | 12 element: 'parameter(m#o)')), |
13 const Test('m(o) { o = 42; }', | 13 const Test('m(o) { o = 42; }', |
14 const Visit(VisitKind.VISIT_PARAMETER_SET, | 14 const Visit(VisitKind.VISIT_PARAMETER_SET, |
15 element: 'parameter(m#o)', | 15 element: 'parameter(m#o)', |
16 rhs:'42')), | 16 rhs:'42')), |
17 const Test('m(o) { o(null, 42); }', | 17 const Test('m(o) { o(null, 42); }', |
18 const Visit(VisitKind.VISIT_PARAMETER_INVOKE, | 18 const Visit(VisitKind.VISIT_PARAMETER_INVOKE, |
19 element: 'parameter(m#o)', | 19 element: 'parameter(m#o)', |
20 arguments: '(null,42)', | 20 arguments: '(null,42)', |
21 selector: 'CallStructure(arity=2)')), | 21 selector: 'CallStructure(arity=2)')), |
22 // TODO(johnniwinther): Expect [VISIT_FINAL_PARAMETER_SET] instead. | |
23 const Test('m(final o) { o = 42; }', | 22 const Test('m(final o) { o = 42; }', |
24 const Visit(VisitKind.VISIT_UNRESOLVED_SET, | 23 const Visit(VisitKind.VISIT_FINAL_PARAMETER_SET, |
25 name: 'o', | 24 element: 'parameter(m#o)', |
26 rhs:'42')), | 25 rhs:'42')), |
27 ], | 26 ], |
28 'Local variables': const [ | 27 'Local variables': const [ |
29 // Local variables | 28 // Local variables |
30 const Test('m() { var o; return o; }', | 29 const Test('m() { var o; return o; }', |
31 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_GET, | 30 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_GET, |
32 element: 'variable(m#o)')), | 31 element: 'variable(m#o)')), |
33 const Test('m() { var o; o = 42; }', | 32 const Test('m() { var o; o = 42; }', |
34 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_SET, | 33 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_SET, |
35 element: 'variable(m#o)', | 34 element: 'variable(m#o)', |
36 rhs:'42')), | 35 rhs:'42')), |
37 const Test('m() { var o; o(null, 42); }', | 36 const Test('m() { var o; o(null, 42); }', |
38 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_INVOKE, | 37 const Visit(VisitKind.VISIT_LOCAL_VARIABLE_INVOKE, |
39 element: 'variable(m#o)', | 38 element: 'variable(m#o)', |
40 arguments: '(null,42)', | 39 arguments: '(null,42)', |
41 selector: 'CallStructure(arity=2)')), | 40 selector: 'CallStructure(arity=2)')), |
42 // TODO(johnniwinther): Expect [VISIT_FINAL_LOCAL_VARIABLE_SET] instead. | |
43 const Test('m() { final o = 0; o = 42; }', | 41 const Test('m() { final o = 0; o = 42; }', |
44 const Visit(VisitKind.VISIT_UNRESOLVED_SET, | 42 const Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_SET, |
45 name: 'o', | 43 element: 'variable(m#o)', |
46 rhs:'42')), | 44 rhs:'42')), |
47 // TODO(johnniwinther): Expect [VISIT_FINAL_LOCAL_VARIABLE_SET] instead. | |
48 const Test('m() { const o = 0; o = 42; }', | 45 const Test('m() { const o = 0; o = 42; }', |
49 const Visit(VisitKind.VISIT_UNRESOLVED_SET, | 46 const Visit(VisitKind.VISIT_FINAL_LOCAL_VARIABLE_SET, |
50 name: 'o', | 47 element: 'variable(m#o)', |
51 rhs:'42')), | 48 rhs:'42')), |
52 ], | 49 ], |
53 'Local functions': const [ | 50 'Local functions': const [ |
54 // Local functions | 51 // Local functions |
55 const Test('m() { o(a, b) {}; return o; }', | 52 const Test('m() { o(a, b) {}; return o; }', |
56 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_GET, | 53 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_GET, |
57 element: 'function(m#o)')), | 54 element: 'function(m#o)')), |
58 const Test('m() { o(a, b) {}; o(null, 42); }', | 55 const Test('m() { o(a, b) {}; o(null, 42); }', |
59 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_INVOKE, | 56 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_INVOKE, |
60 element: 'function(m#o)', | 57 element: 'function(m#o)', |
61 arguments: '(null,42)', | 58 arguments: '(null,42)', |
62 selector: 'CallStructure(arity=2)')), | 59 selector: 'CallStructure(arity=2)')), |
63 const Test('m() { o(a) {}; o(null, 42); }', | 60 const Test('m() { o(a) {}; o(null, 42); }', |
64 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_INCOMPATIBLE_INVOKE, | 61 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_INCOMPATIBLE_INVOKE, |
65 element: 'function(m#o)', | 62 element: 'function(m#o)', |
66 arguments: '(null,42)', | 63 arguments: '(null,42)', |
67 selector: 'CallStructure(arity=2)')), | 64 selector: 'CallStructure(arity=2)')), |
68 // TODO(johnniwinther): Expect [VISIT_LOCAL_FUNCTION_SET] instead. | |
69 const Test('m() { o(a, b) {}; o = 42; }', | 65 const Test('m() { o(a, b) {}; o = 42; }', |
70 const Visit(VisitKind.VISIT_UNRESOLVED_SET, | 66 const Visit(VisitKind.VISIT_LOCAL_FUNCTION_SET, |
71 name: 'o', | 67 element: 'function(m#o)', |
72 rhs: '42')), | 68 rhs: '42')), |
73 ], | 69 ], |
74 'Static fields': const [ | 70 'Static fields': const [ |
75 // Static fields | 71 // Static fields |
76 const Test( | 72 const Test( |
77 ''' | 73 ''' |
78 class C { static var o; } | 74 class C { static var o; } |
79 m() => C.o; | 75 m() => C.o; |
80 ''', | 76 ''', |
81 const Visit(VisitKind.VISIT_STATIC_FIELD_GET, | 77 const Visit(VisitKind.VISIT_STATIC_FIELD_GET, |
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 ''' | 1408 ''' |
1413 class C {} | 1409 class C {} |
1414 m() => C(null, 42); | 1410 m() => C(null, 42); |
1415 ''', | 1411 ''', |
1416 const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_INVOKE, | 1412 const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_INVOKE, |
1417 constant: 'C', | 1413 constant: 'C', |
1418 arguments: '(null,42)')), | 1414 arguments: '(null,42)')), |
1419 const Test( | 1415 const Test( |
1420 ''' | 1416 ''' |
1421 class C {} | 1417 class C {} |
| 1418 m() => C = 42; |
| 1419 ''', |
| 1420 const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_SET, |
| 1421 constant: 'C', |
| 1422 rhs: '42')), |
| 1423 const Test( |
| 1424 ''' |
| 1425 class C {} |
1422 m() => C += 42; | 1426 m() => C += 42; |
1423 ''', | 1427 ''', |
1424 const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_COMPOUND, | 1428 const Visit(VisitKind.VISIT_CLASS_TYPE_LITERAL_COMPOUND, |
1425 constant: 'C', | 1429 constant: 'C', |
1426 operator: '+=', | 1430 operator: '+=', |
1427 rhs: '42')), | 1431 rhs: '42')), |
1428 const Test( | 1432 const Test( |
1429 ''' | 1433 ''' |
1430 class C {} | 1434 class C {} |
1431 m() => ++C; | 1435 m() => ++C; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 ''' | 1470 ''' |
1467 typedef F(); | 1471 typedef F(); |
1468 m() => F(null, 42); | 1472 m() => F(null, 42); |
1469 ''', | 1473 ''', |
1470 const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_INVOKE, | 1474 const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_INVOKE, |
1471 constant: 'F', | 1475 constant: 'F', |
1472 arguments: '(null,42)')), | 1476 arguments: '(null,42)')), |
1473 const Test( | 1477 const Test( |
1474 ''' | 1478 ''' |
1475 typedef F(); | 1479 typedef F(); |
| 1480 m() => F = 42; |
| 1481 ''', |
| 1482 const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_SET, |
| 1483 constant: 'F', |
| 1484 rhs: '42')), |
| 1485 const Test( |
| 1486 ''' |
| 1487 typedef F(); |
1476 m() => F += 42; | 1488 m() => F += 42; |
1477 ''', | 1489 ''', |
1478 const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_COMPOUND, | 1490 const Visit(VisitKind.VISIT_TYPEDEF_TYPE_LITERAL_COMPOUND, |
1479 constant: 'F', | 1491 constant: 'F', |
1480 operator: '+=', | 1492 operator: '+=', |
1481 rhs: '42')), | 1493 rhs: '42')), |
1482 const Test( | 1494 const Test( |
1483 ''' | 1495 ''' |
1484 typedef F(); | 1496 typedef F(); |
1485 m() => ++F; | 1497 m() => ++F; |
(...skipping 25 matching lines...) Expand all Loading... |
1511 class C<T> { | 1523 class C<T> { |
1512 m() => T(null, 42); | 1524 m() => T(null, 42); |
1513 } | 1525 } |
1514 ''', | 1526 ''', |
1515 const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_INVOKE, | 1527 const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_INVOKE, |
1516 element: 'type_variable(C#T)', | 1528 element: 'type_variable(C#T)', |
1517 arguments: '(null,42)')), | 1529 arguments: '(null,42)')), |
1518 const Test.clazz( | 1530 const Test.clazz( |
1519 ''' | 1531 ''' |
1520 class C<T> { | 1532 class C<T> { |
| 1533 m() => T = 42; |
| 1534 } |
| 1535 ''', |
| 1536 const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_SET, |
| 1537 element: 'type_variable(C#T)', |
| 1538 rhs: '42')), |
| 1539 const Test.clazz( |
| 1540 ''' |
| 1541 class C<T> { |
1521 m() => T += 42; | 1542 m() => T += 42; |
1522 } | 1543 } |
1523 ''', | 1544 ''', |
1524 const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_COMPOUND, | 1545 const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_COMPOUND, |
1525 element: 'type_variable(C#T)', | 1546 element: 'type_variable(C#T)', |
1526 operator: '+=', | 1547 operator: '+=', |
1527 rhs: '42')), | 1548 rhs: '42')), |
1528 const Test.clazz( | 1549 const Test.clazz( |
1529 ''' | 1550 ''' |
1530 class C<T> { | 1551 class C<T> { |
(...skipping 2395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3926 rhs: '42')), | 3947 rhs: '42')), |
3927 const Test.prefix( | 3948 const Test.prefix( |
3928 ''' | 3949 ''' |
3929 var o; | 3950 var o; |
3930 ''', | 3951 ''', |
3931 'm() => p?.o;', | 3952 'm() => p?.o;', |
3932 const Visit(VisitKind.ERROR_INVALID_GET, | 3953 const Visit(VisitKind.ERROR_INVALID_GET, |
3933 error: MessageKind.PREFIX_AS_EXPRESSION)), | 3954 error: MessageKind.PREFIX_AS_EXPRESSION)), |
3934 ], | 3955 ], |
3935 }; | 3956 }; |
OLD | NEW |