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 library engine.declaration_resolver_test; | 5 library engine.declaration_resolver_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 test_genericFunction_asTopLevelVariableType() async { | 513 test_genericFunction_asTopLevelVariableType() async { |
514 String code = r''' | 514 String code = r''' |
515 int Function(int, String) v; | 515 int Function(int, String) v; |
516 '''; | 516 '''; |
517 CompilationUnit unit = await resolveSource(code); | 517 CompilationUnit unit = await resolveSource(code); |
518 // re-resolve | 518 // re-resolve |
519 _cloneResolveUnit(unit); | 519 _cloneResolveUnit(unit); |
520 // no other validations than built into DeclarationResolver | 520 // no other validations than built into DeclarationResolver |
521 } | 521 } |
522 | 522 |
| 523 test_genericFunction_asTypeArgument() async { |
| 524 String code = r''' |
| 525 List<Function(int)> v; |
| 526 '''; |
| 527 CompilationUnit unit = await resolveSource(code); |
| 528 // re-resolve |
| 529 _cloneResolveUnit(unit); |
| 530 // no other validations than built into DeclarationResolver |
| 531 } |
| 532 |
| 533 test_genericFunction_asTypeArgument_lessNodes() async { |
| 534 String code = r''' |
| 535 Map<Function<int>> v; |
| 536 '''; |
| 537 CompilationUnit unit = await resolveSource(code); |
| 538 // re-resolve |
| 539 _cloneResolveUnit(unit); |
| 540 // no other validations than built into DeclarationResolver |
| 541 } |
| 542 |
| 543 test_genericFunction_asTypeArgument_moreNodes() async { |
| 544 String code = r''' |
| 545 List<Function<int>, Function<String>> v; |
| 546 '''; |
| 547 CompilationUnit unit = await resolveSource(code); |
| 548 // re-resolve |
| 549 _cloneResolveUnit(unit); |
| 550 // no other validations than built into DeclarationResolver |
| 551 } |
| 552 |
| 553 test_genericFunction_asTypeArgument_noNodes() async { |
| 554 String code = r''' |
| 555 List v; |
| 556 '''; |
| 557 CompilationUnit unit = await resolveSource(code); |
| 558 // re-resolve |
| 559 _cloneResolveUnit(unit); |
| 560 // no other validations than built into DeclarationResolver |
| 561 } |
| 562 |
| 563 test_genericFunction_asTypeArgument_ofInitializer() async { |
| 564 String code = r''' |
| 565 var v = <Function(int)>[]; |
| 566 '''; |
| 567 CompilationUnit unit = await resolveSource(code); |
| 568 CompilationUnit newUnit = _cloneResolveUnit(unit); |
| 569 var v = newUnit.declarations[0] as TopLevelVariableDeclaration; |
| 570 var initializer = v.variables.variables[0].initializer as ListLiteral; |
| 571 expect(initializer.typeArguments.arguments[0].type, isNotNull); |
| 572 } |
| 573 |
523 test_invalid_functionDeclaration_getter_inFunction() async { | 574 test_invalid_functionDeclaration_getter_inFunction() async { |
524 String code = r''' | 575 String code = r''' |
525 var v = (() { | 576 var v = (() { |
526 main() { | 577 main() { |
527 int get zzz => 42; | 578 int get zzz => 42; |
528 } | 579 } |
529 }); | 580 }); |
530 '''; | 581 '''; |
531 CompilationUnit unit = await resolveSource(code); | 582 CompilationUnit unit = await resolveSource(code); |
532 FunctionElement getterElement = | 583 FunctionElement getterElement = |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 expect(element.type.toString(), "<T>(T, T) → T"); | 843 expect(element.type.toString(), "<T>(T, T) → T"); |
793 expect(t.element, same(tElement)); | 844 expect(t.element, same(tElement)); |
794 | 845 |
795 // re-resolve | 846 // re-resolve |
796 CompilationUnit unit2 = _cloneResolveUnit(unit); | 847 CompilationUnit unit2 = _cloneResolveUnit(unit); |
797 node = _findSimpleIdentifier(unit2, code, 'max').parent; | 848 node = _findSimpleIdentifier(unit2, code, 'max').parent; |
798 t = node.typeParameters.typeParameters[0]; | 849 t = node.typeParameters.typeParameters[0]; |
799 expect(t.element, same(tElement)); | 850 expect(t.element, same(tElement)); |
800 } | 851 } |
801 } | 852 } |
OLD | NEW |