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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 element: 'field(C#o)')), | 100 element: 'field(C#o)')), |
101 const Test.prefix( | 101 const Test.prefix( |
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.clazz( |
| 111 ''' |
| 112 class C { |
| 113 var o; |
| 114 static m() => o; |
| 115 } |
| 116 ''', |
| 117 const Visit(VisitKind.ERROR_INVALID_GET, |
| 118 error: MessageKind.NO_INSTANCE_AVAILABLE)), |
110 const Test.prefix( | 119 const Test.prefix( |
111 ''' | 120 ''' |
112 class C { | 121 class C { |
113 static var o; | 122 static var o; |
114 } | 123 } |
115 ''', | 124 ''', |
116 'm() => p.C.o;', | 125 'm() => p.C.o;', |
117 const [ | 126 const [ |
118 const Visit(VisitKind.PREVISIT_DEFERRED_ACCESS, | 127 const Visit(VisitKind.PREVISIT_DEFERRED_ACCESS, |
119 element: 'prefix(p)'), | 128 element: 'prefix(p)'), |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 ], | 191 ], |
183 isDeferred: true), | 192 isDeferred: true), |
184 const Test( | 193 const Test( |
185 ''' | 194 ''' |
186 class C {} | 195 class C {} |
187 m() => C.this; | 196 m() => C.this; |
188 ''', | 197 ''', |
189 null), | 198 null), |
190 const Test( | 199 const Test( |
191 ''' | 200 ''' |
192 class C { static var o; } | 201 class C { |
| 202 static var o; |
| 203 } |
193 m() { C.o = 42; } | 204 m() { C.o = 42; } |
194 ''', | 205 ''', |
195 const Visit(VisitKind.VISIT_STATIC_FIELD_SET, | 206 const Visit(VisitKind.VISIT_STATIC_FIELD_SET, |
196 element: 'field(C#o)', | 207 element: 'field(C#o)', |
197 rhs: '42')), | 208 rhs: '42')), |
198 const Test.clazz( | 209 const Test.clazz( |
199 ''' | 210 ''' |
200 class C { | 211 class C { |
201 static var o; | 212 static var o; |
202 m() { o = 42; } | 213 m() { o = 42; } |
(...skipping 15 matching lines...) Expand all Loading... |
218 const Test.prefix( | 229 const Test.prefix( |
219 ''' | 230 ''' |
220 class C { | 231 class C { |
221 static var o; | 232 static var o; |
222 } | 233 } |
223 ''', | 234 ''', |
224 'm() { p.C.o = 42; }', | 235 'm() { p.C.o = 42; }', |
225 const Visit(VisitKind.VISIT_STATIC_FIELD_SET, | 236 const Visit(VisitKind.VISIT_STATIC_FIELD_SET, |
226 element: 'field(C#o)', | 237 element: 'field(C#o)', |
227 rhs: '42')), | 238 rhs: '42')), |
| 239 const Test.clazz( |
| 240 ''' |
| 241 class C { |
| 242 var o; |
| 243 static m() { o = 42; } |
| 244 } |
| 245 ''', |
| 246 const Visit(VisitKind.ERROR_INVALID_SET, |
| 247 error: MessageKind.NO_INSTANCE_AVAILABLE, |
| 248 rhs: '42')), |
228 const Test( | 249 const Test( |
229 ''' | 250 ''' |
230 class C { static var o; } | 251 class C { |
| 252 static var o; |
| 253 } |
231 m() { C.o(null, 42); } | 254 m() { C.o(null, 42); } |
232 ''', | 255 ''', |
233 const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE, | 256 const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE, |
234 element: 'field(C#o)', | 257 element: 'field(C#o)', |
235 arguments: '(null,42)')), | 258 arguments: '(null,42)')), |
236 const Test.clazz( | 259 const Test.clazz( |
237 ''' | 260 ''' |
238 class C { | 261 class C { |
239 static var o; | 262 static var o; |
240 m() { o(null, 42); } | 263 m() { o(null, 42); } |
241 } | 264 } |
242 ''', | 265 ''', |
243 const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE, | 266 const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE, |
244 element: 'field(C#o)', | 267 element: 'field(C#o)', |
245 arguments: '(null,42)')), | 268 arguments: '(null,42)')), |
246 const Test.clazz( | 269 const Test.clazz( |
247 ''' | 270 ''' |
248 class C { | 271 class C { |
249 static var o; | 272 static var o; |
250 m() { C.o(null, 42); } | 273 m() { C.o(null, 42); } |
251 } | 274 } |
252 ''', | 275 ''', |
253 const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE, | 276 const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE, |
254 element: 'field(C#o)', | 277 element: 'field(C#o)', |
255 arguments: '(null,42)')), | 278 arguments: '(null,42)')), |
| 279 const Test.clazz( |
| 280 ''' |
| 281 class C { |
| 282 var o; |
| 283 static m() { o(null, 42); } |
| 284 } |
| 285 ''', |
| 286 const Visit(VisitKind.ERROR_INVALID_INVOKE, |
| 287 error: MessageKind.NO_INSTANCE_AVAILABLE, |
| 288 arguments: '(null,42)')), |
256 const Test.prefix( | 289 const Test.prefix( |
257 ''' | 290 ''' |
258 class C { | 291 class C { |
259 static var o; | 292 static var o; |
260 } | 293 } |
261 ''', | 294 ''', |
262 'm() { p.C.o(null, 42); }', | 295 'm() { p.C.o(null, 42); }', |
263 const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE, | 296 const Visit(VisitKind.VISIT_STATIC_FIELD_INVOKE, |
264 element: 'field(C#o)', | 297 element: 'field(C#o)', |
265 arguments: '(null,42)')), | 298 arguments: '(null,42)')), |
266 const Test( | 299 const Test( |
267 ''' | 300 ''' |
268 class C {} | 301 class C {} |
269 m() => C.this(null, 42); | 302 m() => C.this(null, 42); |
270 ''', | 303 ''', |
271 const Visit(VisitKind.ERROR_INVALID_INVOKE, | 304 const Visit(VisitKind.ERROR_INVALID_INVOKE, |
272 error: MessageKind.THIS_PROPERTY, arguments: '(null,42)')), | 305 error: MessageKind.THIS_PROPERTY, |
| 306 arguments: '(null,42)')), |
273 // TODO(johnniwinther): Expect [VISIT_FINAL_STATIC_FIELD_SET] instead. | 307 // TODO(johnniwinther): Expect [VISIT_FINAL_STATIC_FIELD_SET] instead. |
274 const Test( | 308 const Test( |
275 ''' | 309 ''' |
276 class C { static final o = 0; } | 310 class C { static final o = 0; } |
277 m() { C.o = 42; } | 311 m() { C.o = 42; } |
278 ''', | 312 ''', |
279 const Visit(VisitKind.VISIT_UNRESOLVED_SET, | 313 const Visit(VisitKind.VISIT_UNRESOLVED_SET, |
280 name: 'o', | 314 name: 'o', |
281 rhs: '42')), | 315 rhs: '42')), |
282 const Test.clazz( | 316 const Test.clazz( |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 operator: '++')), | 1536 operator: '++')), |
1503 const Test.clazz( | 1537 const Test.clazz( |
1504 ''' | 1538 ''' |
1505 class C<T> { | 1539 class C<T> { |
1506 m() => T--; | 1540 m() => T--; |
1507 } | 1541 } |
1508 ''', | 1542 ''', |
1509 const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_POSTFIX, | 1543 const Visit(VisitKind.VISIT_TYPE_VARIABLE_TYPE_LITERAL_POSTFIX, |
1510 element: 'type_variable(C#T)', | 1544 element: 'type_variable(C#T)', |
1511 operator: '--')), | 1545 operator: '--')), |
1512 | 1546 const Test.clazz( |
| 1547 ''' |
| 1548 class C<T> { |
| 1549 static m() => T; |
| 1550 } |
| 1551 ''', |
| 1552 const Visit(VisitKind.ERROR_INVALID_GET, |
| 1553 error: MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER)), |
| 1554 const Test.clazz( |
| 1555 ''' |
| 1556 class C<T> { |
| 1557 static m() => T(null, 42); |
| 1558 } |
| 1559 ''', |
| 1560 const Visit(VisitKind.ERROR_INVALID_INVOKE, |
| 1561 error: MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, |
| 1562 arguments: '(null,42)')), |
| 1563 const Test.clazz( |
| 1564 ''' |
| 1565 class C<T> { |
| 1566 static m() => T += 42; |
| 1567 } |
| 1568 ''', |
| 1569 const Visit(VisitKind.ERROR_INVALID_COMPOUND, |
| 1570 error: MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, |
| 1571 operator: '+=', |
| 1572 rhs: '42')), |
| 1573 const Test.clazz( |
| 1574 ''' |
| 1575 class C<T> { |
| 1576 static m() => ++T; |
| 1577 } |
| 1578 ''', |
| 1579 const Visit(VisitKind.ERROR_INVALID_PREFIX, |
| 1580 error: MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, |
| 1581 operator: '++')), |
| 1582 const Test.clazz( |
| 1583 ''' |
| 1584 class C<T> { |
| 1585 static m() => T--; |
| 1586 } |
| 1587 ''', |
| 1588 const Visit(VisitKind.ERROR_INVALID_POSTFIX, |
| 1589 error: MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, |
| 1590 operator: '--')), |
1513 ], | 1591 ], |
1514 'Dynamic type literals': const [ | 1592 'Dynamic type literals': const [ |
1515 // Dynamic type literals | 1593 // Dynamic type literals |
1516 const Test( | 1594 const Test( |
1517 ''' | 1595 ''' |
1518 m() => dynamic; | 1596 m() => dynamic; |
1519 ''', | 1597 ''', |
1520 const Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_GET, | 1598 const Visit(VisitKind.VISIT_DYNAMIC_TYPE_LITERAL_GET, |
1521 constant: 'dynamic')), | 1599 constant: 'dynamic')), |
1522 // TODO(johnniwinther): Update these to expect the constant to be `dynamic` | 1600 // TODO(johnniwinther): Update these to expect the constant to be `dynamic` |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2227 ''' | 2305 ''' |
2228 class C { | 2306 class C { |
2229 static var a; | 2307 static var a; |
2230 } | 2308 } |
2231 ''', | 2309 ''', |
2232 ''' | 2310 ''' |
2233 m() => p.C.a += 42; | 2311 m() => p.C.a += 42; |
2234 ''', | 2312 ''', |
2235 const Visit(VisitKind.VISIT_STATIC_FIELD_COMPOUND, | 2313 const Visit(VisitKind.VISIT_STATIC_FIELD_COMPOUND, |
2236 element: 'field(C#a)', operator: '+=', rhs: '42')), | 2314 element: 'field(C#a)', operator: '+=', rhs: '42')), |
| 2315 const Test.clazz( |
| 2316 ''' |
| 2317 class C { |
| 2318 var o; |
| 2319 static m() { o += 42; } |
| 2320 } |
| 2321 ''', |
| 2322 const Visit(VisitKind.ERROR_INVALID_COMPOUND, |
| 2323 error: MessageKind.NO_INSTANCE_AVAILABLE, |
| 2324 operator: '+=', |
| 2325 rhs: '42')), |
2237 const Test( | 2326 const Test( |
2238 ''' | 2327 ''' |
2239 class C { | 2328 class C { |
2240 static get a => 0; | 2329 static get a => 0; |
2241 static set a(_) {} | 2330 static set a(_) {} |
2242 } | 2331 } |
2243 m() => C.a += 42; | 2332 m() => C.a += 42; |
2244 ''', | 2333 ''', |
2245 const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_COMPOUND, | 2334 const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_COMPOUND, |
2246 getter: 'getter(C#a)', setter: 'setter(C#a)', | 2335 getter: 'getter(C#a)', setter: 'setter(C#a)', |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2742 ''' | 2831 ''' |
2743 class C { | 2832 class C { |
2744 static var a; | 2833 static var a; |
2745 } | 2834 } |
2746 ''', | 2835 ''', |
2747 ''' | 2836 ''' |
2748 m() => --p.C.a; | 2837 m() => --p.C.a; |
2749 ''', | 2838 ''', |
2750 const Visit(VisitKind.VISIT_STATIC_FIELD_PREFIX, | 2839 const Visit(VisitKind.VISIT_STATIC_FIELD_PREFIX, |
2751 element: 'field(C#a)', operator: '--')), | 2840 element: 'field(C#a)', operator: '--')), |
| 2841 const Test.clazz( |
| 2842 ''' |
| 2843 class C { |
| 2844 var o; |
| 2845 static m() { ++o; } |
| 2846 } |
| 2847 ''', |
| 2848 const Visit(VisitKind.ERROR_INVALID_PREFIX, |
| 2849 error: MessageKind.NO_INSTANCE_AVAILABLE, |
| 2850 operator: '++')), |
2752 const Test( | 2851 const Test( |
2753 ''' | 2852 ''' |
2754 class C { | 2853 class C { |
2755 static get a => 0; | 2854 static get a => 0; |
2756 static set a(_) {} | 2855 static set a(_) {} |
2757 } | 2856 } |
2758 m() => ++C.a; | 2857 m() => ++C.a; |
2759 ''', | 2858 ''', |
2760 const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_PREFIX, | 2859 const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_PREFIX, |
2761 getter: 'getter(C#a)', setter: 'setter(C#a)', | 2860 getter: 'getter(C#a)', setter: 'setter(C#a)', |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3123 ''' | 3222 ''' |
3124 class C { | 3223 class C { |
3125 static var a; | 3224 static var a; |
3126 } | 3225 } |
3127 ''', | 3226 ''', |
3128 ''' | 3227 ''' |
3129 m() => p.C.a--; | 3228 m() => p.C.a--; |
3130 ''', | 3229 ''', |
3131 const Visit(VisitKind.VISIT_STATIC_FIELD_POSTFIX, | 3230 const Visit(VisitKind.VISIT_STATIC_FIELD_POSTFIX, |
3132 element: 'field(C#a)', operator: '--')), | 3231 element: 'field(C#a)', operator: '--')), |
| 3232 const Test.clazz( |
| 3233 ''' |
| 3234 class C { |
| 3235 var o; |
| 3236 static m() { o--; } |
| 3237 } |
| 3238 ''', |
| 3239 const Visit(VisitKind.ERROR_INVALID_POSTFIX, |
| 3240 error: MessageKind.NO_INSTANCE_AVAILABLE, |
| 3241 operator: '--')), |
3133 const Test( | 3242 const Test( |
3134 ''' | 3243 ''' |
3135 class C { | 3244 class C { |
3136 static get a => 0; | 3245 static get a => 0; |
3137 static set a(_) {} | 3246 static set a(_) {} |
3138 } | 3247 } |
3139 m() => C.a++; | 3248 m() => C.a++; |
3140 ''', | 3249 ''', |
3141 const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_POSTFIX, | 3250 const Visit(VisitKind.VISIT_STATIC_GETTER_SETTER_POSTFIX, |
3142 getter: 'getter(C#a)', setter: 'setter(C#a)', | 3251 getter: 'getter(C#a)', setter: 'setter(C#a)', |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3816 ''' | 3925 ''' |
3817 m(a) => a ??= 42; | 3926 m(a) => a ??= 42; |
3818 ''', | 3927 ''', |
3819 const Visit( | 3928 const Visit( |
3820 VisitKind.VISIT_PARAMETER_COMPOUND, | 3929 VisitKind.VISIT_PARAMETER_COMPOUND, |
3821 element: 'parameter(m#a)', | 3930 element: 'parameter(m#a)', |
3822 operator: '??=', | 3931 operator: '??=', |
3823 rhs: '42')), | 3932 rhs: '42')), |
3824 ], | 3933 ], |
3825 }; | 3934 }; |
OLD | NEW |