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

Side by Side Diff: tests/compiler/dart2js/semantic_visitor_test.dart

Issue 1120633002: Refactor index operator in SimpleTypeInferrer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix bug. Created 5 years, 7 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 | Annotate | Revision Log
OLDNEW
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 library dart2js.semantics_visitor_test; 5 library dart2js.semantics_visitor_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 import 'package:compiler/src/constants/expressions.dart'; 10 import 'package:compiler/src/constants/expressions.dart';
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 } 1243 }
1244 ''', 1244 ''',
1245 const Visit(VisitKind.VISIT_SUPER_INDEX_PREFIX, 1245 const Visit(VisitKind.VISIT_SUPER_INDEX_PREFIX,
1246 getter: 'function(B#[])', 1246 getter: 'function(B#[])',
1247 setter: 'function(B#[]=)', 1247 setter: 'function(B#[]=)',
1248 index: '42', 1248 index: '42',
1249 operator: '++')), 1249 operator: '++')),
1250 const Test.clazz( 1250 const Test.clazz(
1251 ''' 1251 '''
1252 class B { 1252 class B {
1253 operator []=(a, b) {}
1254 }
1255 class C extends B {
1256 m() => ++super[42];
1257 }
1258 ''',
1259 const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_PREFIX,
1260 index: '42',
1261 operator: '++')),
1262 const Test.clazz(
1263 '''
1264 class B {
1265 }
1266 class C extends B {
1267 m() => ++super[42];
1268 }
1269 ''',
1270 const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_PREFIX,
1271 index: '42',
1272 operator: '++')),
1273 const Test.clazz(
1274 '''
1275 class B {
1276 operator [](_) => null;
1277 }
1278 class C extends B {
1279 m() => ++super[42];
1280 }
1281 ''',
1282 const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_INDEX_PREFIX,
1283 getter: 'function(B#[])',
1284 index: '42',
1285 operator: '++')),
1286 const Test.clazz(
1287 '''
1288 class B {
1253 operator [](_) => null; 1289 operator [](_) => null;
1254 operator []=(a, b) {} 1290 operator []=(a, b) {}
1255 } 1291 }
1256 class C extends B { 1292 class C extends B {
1257 m() => super[42]--; 1293 m() => super[42]--;
1258 } 1294 }
1259 ''', 1295 ''',
1260 const Visit(VisitKind.VISIT_SUPER_INDEX_POSTFIX, 1296 const Visit(VisitKind.VISIT_SUPER_INDEX_POSTFIX,
1261 getter: 'function(B#[])', 1297 getter: 'function(B#[])',
1262 setter: 'function(B#[]=)', 1298 setter: 'function(B#[]=)',
1263 index: '42', 1299 index: '42',
1264 operator: '--')), 1300 operator: '--')),
1301 const Test.clazz(
1302 '''
1303 class B {
1304 operator []=(a, b) {}
1305 }
1306 class C extends B {
1307 m() => super[42]--;
1308 }
1309 ''',
1310 const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_POSTFIX,
1311 index: '42',
1312 operator: '--')),
1313 const Test.clazz(
1314 '''
1315 class B {
1316 }
1317 class C extends B {
1318 m() => super[42]--;
1319 }
1320 ''',
1321 const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_POSTFIX,
1322 index: '42',
1323 operator: '--')),
1324 const Test.clazz(
1325 '''
1326 class B {
1327 operator [](_) => null;
1328 }
1329 class C extends B {
1330 m() => super[42]--;
1331 }
1332 ''',
1333 const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_INDEX_POSTFIX,
1334 getter: 'function(B#[])',
1335 index: '42',
1336 operator: '--')),
1265 ], 1337 ],
1266 'Equals': const [ 1338 'Equals': const [
1267 // Equals 1339 // Equals
1268 const Test( 1340 const Test(
1269 ''' 1341 '''
1270 m() => 2 == 3; 1342 m() => 2 == 3;
1271 ''', 1343 ''',
1272 const Visit(VisitKind.VISIT_EQUALS, 1344 const Visit(VisitKind.VISIT_EQUALS,
1273 left: '2', right: '3')), 1345 left: '2', right: '3')),
1274 const Test.clazz( 1346 const Test.clazz(
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 ''' 1442 '''
1371 class B { 1443 class B {
1372 operator []=(a, b) {} 1444 operator []=(a, b) {}
1373 } 1445 }
1374 class C extends B { 1446 class C extends B {
1375 m() => super[1] = 2; 1447 m() => super[1] = 2;
1376 } 1448 }
1377 ''', 1449 ''',
1378 const Visit(VisitKind.VISIT_SUPER_INDEX_SET, 1450 const Visit(VisitKind.VISIT_SUPER_INDEX_SET,
1379 element: 'function(B#[]=)', index: '1', rhs: '2')), 1451 element: 'function(B#[]=)', index: '1', rhs: '2')),
1452 const Test.clazz(
1453 '''
1454 class B {
1455 }
1456 class C extends B {
1457 m() => super[1] = 2;
1458 }
1459 ''',
1460 const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX_SET,
1461 index: '1', rhs: '2')),
1380 ], 1462 ],
1381 'Compound assignment': const [ 1463 'Compound assignment': const [
1382 // Compound assignment 1464 // Compound assignment
1383 const Test( 1465 const Test(
1384 ''' 1466 '''
1385 m(a) => a.b += 42; 1467 m(a) => a.b += 42;
1386 ''', 1468 ''',
1387 const [ 1469 const [
1388 const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_COMPOUND, 1470 const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_COMPOUND,
1389 receiver: 'a', operator: '+=', rhs: '42', 1471 receiver: 'a', operator: '+=', rhs: '42',
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 operator: '+=', rhs: '42')),*/ 1780 operator: '+=', rhs: '42')),*/
1699 ], 1781 ],
1700 'Compound index assignment': const [ 1782 'Compound index assignment': const [
1701 // Compound index assignment 1783 // Compound index assignment
1702 const Test( 1784 const Test(
1703 ''' 1785 '''
1704 m() => 0[1] += 42; 1786 m() => 0[1] += 42;
1705 ''', 1787 ''',
1706 const Visit(VisitKind.VISIT_COMPOUND_INDEX_SET, 1788 const Visit(VisitKind.VISIT_COMPOUND_INDEX_SET,
1707 receiver: '0', index: '1', operator: '+=', rhs: '42')), 1789 receiver: '0', index: '1', operator: '+=', rhs: '42')),
1708 // TODO(johnniwinther): Enable this when the getter element is stored. 1790 const Test.clazz(
1709 /*const Test.clazz(
1710 ''' 1791 '''
1711 class B { 1792 class B {
1712 operator [](_) {} 1793 operator [](_) {}
1713 operator []=(a, b) {} 1794 operator []=(a, b) {}
1714 } 1795 }
1715 class C extends B { 1796 class C extends B {
1716 m() => super[1] += 42; 1797 m() => super[1] += 42;
1717 } 1798 }
1718 ''', 1799 ''',
1719 const Visit(VisitKind.VISIT_SUPER_COMPOUND_INDEX_SET, 1800 const Visit(VisitKind.VISIT_SUPER_COMPOUND_INDEX_SET,
1720 getter: 'function(B#[])', setter: 'function(B#[]=)', 1801 getter: 'function(B#[])', setter: 'function(B#[]=)',
1721 index: '1', operator: '+=', rhs: '42')),*/ 1802 index: '1', operator: '+=', rhs: '42')),
1803 const Test.clazz(
1804 '''
1805 class B {
1806 operator []=(a, b) {}
1807 }
1808 class C extends B {
1809 m() => super[1] += 42;
1810 }
1811 ''',
1812 const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_COMPOUND_INDEX_SET,
1813 index: '1', operator: '+=', rhs: '42')),
1814 const Test.clazz(
1815 '''
1816 class B {
1817 }
1818 class C extends B {
1819 m() => super[1] += 42;
1820 }
1821 ''',
1822 const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_COMPOUND_INDEX_SET,
1823 index: '1', operator: '+=', rhs: '42')),
1824 const Test.clazz(
1825 '''
1826 class B {
1827 operator [](_) {}
1828 }
1829 class C extends B {
1830 m() => super[1] += 42;
1831 }
1832 ''',
1833 const Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_COMPOUND_INDEX_SET,
1834 getter: 'function(B#[])',
1835 index: '1', operator: '+=', rhs: '42')),
1722 ], 1836 ],
1723 'Prefix expression': const [ 1837 'Prefix expression': const [
1724 // Prefix expression 1838 // Prefix expression
1725 const Test( 1839 const Test(
1726 ''' 1840 '''
1727 m(a) => --a.b; 1841 m(a) => --a.b;
1728 ''', 1842 ''',
1729 const [ 1843 const [
1730 const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_PREFIX, 1844 const Visit(VisitKind.VISIT_DYNAMIC_PROPERTY_PREFIX,
1731 receiver: 'a', operator: '--', 1845 receiver: 'a', operator: '--',
(...skipping 3445 matching lines...) Expand 10 before | Expand all | Expand 10 after
5177 @override 5291 @override
5178 errorUndefinedUnaryExpression( 5292 errorUndefinedUnaryExpression(
5179 Send node, 5293 Send node,
5180 Operator operator, 5294 Operator operator,
5181 Node expression, 5295 Node expression,
5182 arg) { 5296 arg) {
5183 // TODO: implement errorUndefinedUnaryExpression 5297 // TODO: implement errorUndefinedUnaryExpression
5184 } 5298 }
5185 5299
5186 @override 5300 @override
5187 errorUnresolvedSuperCompoundIndexSet( 5301 visitUnresolvedSuperGetterCompoundIndexSet(
5188 Send node, 5302 Send node,
5189 ErroneousElement element, 5303 Element element,
5190 Node index, 5304 Node index,
5191 AssignmentOperator operator, 5305 AssignmentOperator operator,
5192 Node rhs, 5306 Node rhs,
5193 arg) { 5307 arg) {
5194 // TODO: implement errorUnresolvedSuperCompoundIndexSet 5308 visits.add(new Visit(
5309 VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_COMPOUND_INDEX_SET,
5310 index: index, operator: operator, rhs: rhs));
5311 apply(index, arg);
5312 apply(rhs, arg);
5195 } 5313 }
5196 5314
5197 @override 5315 @override
5198 errorUnresolvedSuperIndexSet( 5316 visitUnresolvedSuperSetterCompoundIndexSet(
5317 Send node,
5318 MethodElement getter,
5319 Element element,
5320 Node index,
5321 AssignmentOperator operator,
5322 Node rhs,
5323 arg) {
5324 visits.add(new Visit(
5325 VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_COMPOUND_INDEX_SET,
5326 getter: getter, index: index, operator: operator, rhs: rhs));
5327 apply(index, arg);
5328 apply(rhs, arg);
5329 }
5330
5331 @override
5332 visitUnresolvedSuperIndexSet(
5199 Send node, 5333 Send node,
5200 ErroneousElement element, 5334 ErroneousElement element,
5201 Node index, 5335 Node index,
5202 Node rhs, 5336 Node rhs,
5203 arg) { 5337 arg) {
5204 // TODO: implement errorUnresolvedSuperIndexSet 5338 visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_INDEX_SET,
5339 index: index, rhs: rhs));
5340 apply(index, arg);
5341 apply(rhs, arg);
5205 } 5342 }
5206 5343
5207 @override 5344 @override
5208 errorUnresolvedSuperIndexPostfix( 5345 visitUnresolvedSuperGetterIndexPostfix(
5209 Send node, 5346 Send node,
5210 Element function, 5347 Element element,
5211 Node index, 5348 Node index,
5212 IncDecOperator operator, 5349 IncDecOperator operator,
5213 arg) { 5350 arg) {
5214 // TODO: implement errorUnresolvedSuperIndexPostfix 5351 visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_POSTFIX,
5352 index: index, operator: operator));
5353 apply(index, arg);
5215 } 5354 }
5216 5355
5217 @override 5356 @override
5218 errorUnresolvedSuperIndexPrefix( 5357 visitUnresolvedSuperSetterIndexPostfix(
5219 Send node, 5358 Send node,
5220 Element function, 5359 MethodElement getter,
5360 Element element,
5221 Node index, 5361 Node index,
5222 IncDecOperator operator, 5362 IncDecOperator operator,
5223 arg) { 5363 arg) {
5224 // TODO: implement errorUnresolvedSuperIndexPrefix 5364 visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_INDEX_POSTFIX,
5365 getter: getter, index: index, operator: operator));
5366 apply(index, arg);
5225 } 5367 }
5226 5368
5227 @override 5369 @override
5370 visitUnresolvedSuperGetterIndexPrefix(
5371 Send node,
5372 Element element,
5373 Node index,
5374 IncDecOperator operator,
5375 arg) {
5376 visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_GETTER_INDEX_PREFIX,
karlklose 2015/05/11 10:38:56 Consider adding a helper for 'visits.add(new Visit
Johnni Winther 2015/05/11 13:04:29 Acknowledged.
5377 index: index, operator: operator));
5378 apply(index, arg);
5379 }
5380
5381 @override
5382 visitUnresolvedSuperSetterIndexPrefix(
5383 Send node,
5384 MethodElement getter,
5385 Element element,
5386 Node index,
5387 IncDecOperator operator,
5388 arg) {
5389 visits.add(new Visit(VisitKind.VISIT_UNRESOLVED_SUPER_SETTER_INDEX_PREFIX,
5390 getter: getter, index: index, operator: operator));
5391 apply(index, arg);
5392 }
5393
5394 @override
5228 visitIndexPostfix( 5395 visitIndexPostfix(
5229 Send node, 5396 Send node,
5230 Node receiver, 5397 Node receiver,
5231 Node index, 5398 Node index,
5232 IncDecOperator operator, 5399 IncDecOperator operator,
5233 arg) { 5400 arg) {
5234 visits.add(new Visit(VisitKind.VISIT_INDEX_POSTFIX, 5401 visits.add(new Visit(VisitKind.VISIT_INDEX_POSTFIX,
5235 receiver: receiver, index: index, operator: operator)); 5402 receiver: receiver, index: index, operator: operator));
5236 apply(receiver, arg); 5403 apply(receiver, arg);
5237 apply(index, arg); 5404 apply(index, arg);
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
6169 VISIT_INDEX_PREFIX, 6336 VISIT_INDEX_PREFIX,
6170 VISIT_INDEX_POSTFIX, 6337 VISIT_INDEX_POSTFIX,
6171 6338
6172 VISIT_SUPER_BINARY, 6339 VISIT_SUPER_BINARY,
6173 VISIT_UNRESOLVED_SUPER_BINARY, 6340 VISIT_UNRESOLVED_SUPER_BINARY,
6174 VISIT_SUPER_INDEX, 6341 VISIT_SUPER_INDEX,
6175 VISIT_UNRESOLVED_SUPER_INDEX, 6342 VISIT_UNRESOLVED_SUPER_INDEX,
6176 VISIT_SUPER_EQUALS, 6343 VISIT_SUPER_EQUALS,
6177 VISIT_SUPER_NOT_EQUALS, 6344 VISIT_SUPER_NOT_EQUALS,
6178 VISIT_SUPER_INDEX_PREFIX, 6345 VISIT_SUPER_INDEX_PREFIX,
6346 VISIT_UNRESOLVED_SUPER_GETTER_INDEX_PREFIX,
6347 VISIT_UNRESOLVED_SUPER_SETTER_INDEX_PREFIX,
6179 VISIT_SUPER_INDEX_POSTFIX, 6348 VISIT_SUPER_INDEX_POSTFIX,
6349 VISIT_UNRESOLVED_SUPER_GETTER_INDEX_POSTFIX,
6350 VISIT_UNRESOLVED_SUPER_SETTER_INDEX_POSTFIX,
6180 6351
6181 VISIT_UNARY, 6352 VISIT_UNARY,
6182 VISIT_SUPER_UNARY, 6353 VISIT_SUPER_UNARY,
6183 VISIT_UNRESOLVED_SUPER_UNARY, 6354 VISIT_UNRESOLVED_SUPER_UNARY,
6184 VISIT_NOT, 6355 VISIT_NOT,
6185 6356
6186 VISIT_EXPRESSION_INVOKE, 6357 VISIT_EXPRESSION_INVOKE,
6187 6358
6188 VISIT_CLASS_TYPE_LITERAL_GET, 6359 VISIT_CLASS_TYPE_LITERAL_GET,
6189 VISIT_CLASS_TYPE_LITERAL_SET, 6360 VISIT_CLASS_TYPE_LITERAL_SET,
(...skipping 23 matching lines...) Expand all
6213 VISIT_DYNAMIC_TYPE_LITERAL_SET, 6384 VISIT_DYNAMIC_TYPE_LITERAL_SET,
6214 VISIT_DYNAMIC_TYPE_LITERAL_INVOKE, 6385 VISIT_DYNAMIC_TYPE_LITERAL_INVOKE,
6215 VISIT_DYNAMIC_TYPE_LITERAL_BINARY, 6386 VISIT_DYNAMIC_TYPE_LITERAL_BINARY,
6216 ERROR_DYNAMIC_TYPE_LITERAL_COMPOUND, 6387 ERROR_DYNAMIC_TYPE_LITERAL_COMPOUND,
6217 ERROR_DYNAMIC_TYPE_LITERAL_PREFIX, 6388 ERROR_DYNAMIC_TYPE_LITERAL_PREFIX,
6218 ERROR_DYNAMIC_TYPE_LITERAL_POSTFIX, 6389 ERROR_DYNAMIC_TYPE_LITERAL_POSTFIX,
6219 6390
6220 VISIT_INDEX_SET, 6391 VISIT_INDEX_SET,
6221 VISIT_COMPOUND_INDEX_SET, 6392 VISIT_COMPOUND_INDEX_SET,
6222 VISIT_SUPER_INDEX_SET, 6393 VISIT_SUPER_INDEX_SET,
6394 VISIT_UNRESOLVED_SUPER_INDEX_SET,
6223 VISIT_SUPER_COMPOUND_INDEX_SET, 6395 VISIT_SUPER_COMPOUND_INDEX_SET,
6396 VISIT_UNRESOLVED_SUPER_GETTER_COMPOUND_INDEX_SET,
6397 VISIT_UNRESOLVED_SUPER_SETTER_COMPOUND_INDEX_SET,
6224 6398
6225 VISIT_ASSERT, 6399 VISIT_ASSERT,
6226 VISIT_LOGICAL_AND, 6400 VISIT_LOGICAL_AND,
6227 VISIT_LOGICAL_OR, 6401 VISIT_LOGICAL_OR,
6228 VISIT_IS, 6402 VISIT_IS,
6229 VISIT_IS_NOT, 6403 VISIT_IS_NOT,
6230 VISIT_AS, 6404 VISIT_AS,
6231 6405
6232 VISIT_CONST_CONSTRUCTOR_INVOKE, 6406 VISIT_CONST_CONSTRUCTOR_INVOKE,
6233 VISIT_GENERATIVE_CONSTRUCTOR_INVOKE, 6407 VISIT_GENERATIVE_CONSTRUCTOR_INVOKE,
(...skipping 27 matching lines...) Expand all
6261 VISIT_OPTIONAL_PARAMETER_DECL, 6435 VISIT_OPTIONAL_PARAMETER_DECL,
6262 VISIT_NAMED_PARAMETER_DECL, 6436 VISIT_NAMED_PARAMETER_DECL,
6263 VISIT_REQUIRED_INITIALIZING_FORMAL_DECL, 6437 VISIT_REQUIRED_INITIALIZING_FORMAL_DECL,
6264 VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL, 6438 VISIT_OPTIONAL_INITIALIZING_FORMAL_DECL,
6265 VISIT_NAMED_INITIALIZING_FORMAL_DECL, 6439 VISIT_NAMED_INITIALIZING_FORMAL_DECL,
6266 6440
6267 ERROR_UNRESOLVED_POSTFIX, 6441 ERROR_UNRESOLVED_POSTFIX,
6268 6442
6269 // TODO(johnniwinther): Add tests for more error cases. 6443 // TODO(johnniwinther): Add tests for more error cases.
6270 } 6444 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698