OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.simple_resolver_test; | 5 library analyzer.test.generated.simple_resolver_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/visitor.dart'; | 8 import 'package:analyzer/dart/ast/visitor.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 } | 649 } |
650 class A { | 650 class A { |
651 void sort([compare = Comparable.compare]) {} | 651 void sort([compare = Comparable.compare]) {} |
652 }'''); | 652 }'''); |
653 computeLibrarySourceErrors(source); | 653 computeLibrarySourceErrors(source); |
654 assertNoErrors(source); | 654 assertNoErrors(source); |
655 verify([source]); | 655 verify([source]); |
656 } | 656 } |
657 | 657 |
658 void test_fieldFormalParameter() { | 658 void test_fieldFormalParameter() { |
| 659 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 660 options.enableInitializingFormalAccess = true; |
| 661 resetWithOptions(options); |
659 Source source = addSource(r''' | 662 Source source = addSource(r''' |
660 class A { | 663 class A { |
661 int x; | 664 int x; |
662 A(this.x) {} | 665 int y; |
| 666 A(this.x) : y = x {} |
663 }'''); | 667 }'''); |
| 668 CompilationUnit unit = |
| 669 analysisContext2.resolveCompilationUnit2(source, source); |
| 670 ClassDeclaration classA = unit.declarations[0]; |
| 671 FieldDeclaration field = classA.members[0]; |
| 672 ConstructorDeclaration constructor = classA.members[2]; |
| 673 ParameterElement paramElement = |
| 674 constructor.parameters.parameters[0].element; |
| 675 expect(paramElement, new isInstanceOf<FieldFormalParameterElement>()); |
| 676 expect((paramElement as FieldFormalParameterElement).field, |
| 677 field.fields.variables[0].element); |
| 678 ConstructorFieldInitializer initializer = constructor.initializers[0]; |
| 679 SimpleIdentifier identifierX = initializer.expression; |
| 680 expect(identifierX.staticElement, paramElement); |
| 681 |
664 computeLibrarySourceErrors(source); | 682 computeLibrarySourceErrors(source); |
665 assertNoErrors(source); | 683 assertNoErrors(source); |
666 verify([source]); | 684 verify([source]); |
667 } | 685 } |
668 | 686 |
669 void test_forEachLoops_nonConflicting() { | 687 void test_forEachLoops_nonConflicting() { |
670 Source source = addSource(r''' | 688 Source source = addSource(r''' |
671 f() { | 689 f() { |
672 List list = [1,2,3]; | 690 List list = [1,2,3]; |
673 for (int x in list) {} | 691 for (int x in list) {} |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1815 // check propagated type | 1833 // check propagated type |
1816 FunctionType propagatedType = node.propagatedType as FunctionType; | 1834 FunctionType propagatedType = node.propagatedType as FunctionType; |
1817 expect(propagatedType.returnType, test.typeProvider.stringType); | 1835 expect(propagatedType.returnType, test.typeProvider.stringType); |
1818 } on AnalysisException catch (e, stackTrace) { | 1836 } on AnalysisException catch (e, stackTrace) { |
1819 thrownException[0] = new CaughtException(e, stackTrace); | 1837 thrownException[0] = new CaughtException(e, stackTrace); |
1820 } | 1838 } |
1821 } | 1839 } |
1822 return null; | 1840 return null; |
1823 } | 1841 } |
1824 } | 1842 } |
OLD | NEW |