OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.test.generated.resolver_test; | 5 library analyzer.test.generated.resolver_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 expect(identifier.propagatedType, same(null)); | 1197 expect(identifier.propagatedType, same(null)); |
1198 } | 1198 } |
1199 { | 1199 { |
1200 SimpleIdentifier identifier = EngineTestCase.findNode( | 1200 SimpleIdentifier identifier = EngineTestCase.findNode( |
1201 unit, code, "v; // return", (node) => node is SimpleIdentifier); | 1201 unit, code, "v; // return", (node) => node is SimpleIdentifier); |
1202 expect(identifier.staticType, same(typeProvider.intType)); | 1202 expect(identifier.staticType, same(typeProvider.intType)); |
1203 expect(identifier.propagatedType, same(null)); | 1203 expect(identifier.propagatedType, same(null)); |
1204 } | 1204 } |
1205 } | 1205 } |
1206 | 1206 |
| 1207 test_assignment_throwExpression() async { |
| 1208 Source source = addSource(r''' |
| 1209 f() { |
| 1210 var v = 1; |
| 1211 v = throw 2; |
| 1212 return v; |
| 1213 }'''); |
| 1214 CompilationUnit unit = await _computeResolvedUnit(source, noErrors: false); |
| 1215 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 1216 BlockFunctionBody body = |
| 1217 function.functionExpression.body as BlockFunctionBody; |
| 1218 ReturnStatement statement = body.block.statements[2] as ReturnStatement; |
| 1219 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; |
| 1220 expect(variableName.propagatedType, same(typeProvider.intType)); |
| 1221 } |
| 1222 |
1207 test_CanvasElement_getContext() async { | 1223 test_CanvasElement_getContext() async { |
1208 String code = r''' | 1224 String code = r''' |
1209 import 'dart:html'; | 1225 import 'dart:html'; |
1210 main(CanvasElement canvas) { | 1226 main(CanvasElement canvas) { |
1211 var context = canvas.getContext('2d'); | 1227 var context = canvas.getContext('2d'); |
1212 }'''; | 1228 }'''; |
1213 Source source = addSource(code); | 1229 Source source = addSource(code); |
1214 CompilationUnit unit = await _computeResolvedUnit(source); | 1230 CompilationUnit unit = await _computeResolvedUnit(source); |
1215 SimpleIdentifier identifier = EngineTestCase.findNode( | 1231 SimpleIdentifier identifier = EngineTestCase.findNode( |
1216 unit, code, "context", (node) => node is SimpleIdentifier); | 1232 unit, code, "context", (node) => node is SimpleIdentifier); |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1588 expect(identifier.propagatedType, same(null)); | 1604 expect(identifier.propagatedType, same(null)); |
1589 } | 1605 } |
1590 { | 1606 { |
1591 SimpleIdentifier identifier = EngineTestCase.findNode( | 1607 SimpleIdentifier identifier = EngineTestCase.findNode( |
1592 unit, code, "v; // marker", (node) => node is SimpleIdentifier); | 1608 unit, code, "v; // marker", (node) => node is SimpleIdentifier); |
1593 expect(identifier.staticType, same(typeProvider.intType)); | 1609 expect(identifier.staticType, same(typeProvider.intType)); |
1594 expect(identifier.propagatedType, same(null)); | 1610 expect(identifier.propagatedType, same(null)); |
1595 } | 1611 } |
1596 } | 1612 } |
1597 | 1613 |
| 1614 test_initializer_throwExpression() async { |
| 1615 Source source = addSource(r''' |
| 1616 f() { |
| 1617 var v = throw 2; |
| 1618 return v; |
| 1619 }'''); |
| 1620 CompilationUnit unit = await _computeResolvedUnit(source, noErrors: false); |
| 1621 FunctionDeclaration function = unit.declarations[0] as FunctionDeclaration; |
| 1622 BlockFunctionBody body = |
| 1623 function.functionExpression.body as BlockFunctionBody; |
| 1624 var statement = body.block.statements[0] as VariableDeclarationStatement; |
| 1625 SimpleIdentifier variableName = statement.variables.variables[0].name; |
| 1626 expect(variableName.propagatedType, isNull); |
| 1627 } |
| 1628 |
1598 test_invocation_target_prefixed() async { | 1629 test_invocation_target_prefixed() async { |
1599 addNamedSource( | 1630 addNamedSource( |
1600 '/helper.dart', | 1631 '/helper.dart', |
1601 ''' | 1632 ''' |
1602 library helper; | 1633 library helper; |
1603 int max(int x, int y) => 0; | 1634 int max(int x, int y) => 0; |
1604 '''); | 1635 '''); |
1605 String code = ''' | 1636 String code = ''' |
1606 import 'helper.dart' as helper; | 1637 import 'helper.dart' as helper; |
1607 main() { | 1638 main() { |
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3589 */ | 3620 */ |
3590 class _StaleElement extends ElementImpl { | 3621 class _StaleElement extends ElementImpl { |
3591 _StaleElement() : super("_StaleElement", -1); | 3622 _StaleElement() : super("_StaleElement", -1); |
3592 | 3623 |
3593 @override | 3624 @override |
3594 get kind => throw "_StaleElement's kind shouldn't be accessed"; | 3625 get kind => throw "_StaleElement's kind shouldn't be accessed"; |
3595 | 3626 |
3596 @override | 3627 @override |
3597 /*=T*/ accept/*<T>*/(_) => throw "_StaleElement shouldn't be visited"; | 3628 /*=T*/ accept/*<T>*/(_) => throw "_StaleElement shouldn't be visited"; |
3598 } | 3629 } |
OLD | NEW |