| 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.src.dart.element.element_test; | 5 library analyzer.test.src.dart.element.element_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/dart/element/type.dart'; | 9 import 'package:analyzer/dart/element/type.dart'; |
| 10 import 'package:analyzer/src/dart/element/element.dart'; | 10 import 'package:analyzer/src/dart/element/element.dart'; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 show AnalysisContextHelper; | 23 show AnalysisContextHelper; |
| 24 import '../../../generated/test_support.dart'; | 24 import '../../../generated/test_support.dart'; |
| 25 import '../../../reflective_tests.dart'; | 25 import '../../../reflective_tests.dart'; |
| 26 import '../../../utils.dart'; | 26 import '../../../utils.dart'; |
| 27 | 27 |
| 28 main() { | 28 main() { |
| 29 initializeTestEnvironment(); | 29 initializeTestEnvironment(); |
| 30 runReflectiveTests(FieldElementImplTest); | 30 runReflectiveTests(FieldElementImplTest); |
| 31 runReflectiveTests(FunctionTypeImplTest); | 31 runReflectiveTests(FunctionTypeImplTest); |
| 32 runReflectiveTests(InterfaceTypeImplTest); | 32 runReflectiveTests(InterfaceTypeImplTest); |
| 33 runReflectiveTests(LocalVariableElementImplTest); |
| 33 runReflectiveTests(TypeParameterTypeImplTest); | 34 runReflectiveTests(TypeParameterTypeImplTest); |
| 34 runReflectiveTests(VoidTypeImplTest); | 35 runReflectiveTests(VoidTypeImplTest); |
| 35 runReflectiveTests(ClassElementImplTest); | 36 runReflectiveTests(ClassElementImplTest); |
| 36 runReflectiveTests(CompilationUnitElementImplTest); | 37 runReflectiveTests(CompilationUnitElementImplTest); |
| 37 runReflectiveTests(ElementLocationImplTest); | 38 runReflectiveTests(ElementLocationImplTest); |
| 38 runReflectiveTests(ElementImplTest); | 39 runReflectiveTests(ElementImplTest); |
| 39 runReflectiveTests(LibraryElementImplTest); | 40 runReflectiveTests(LibraryElementImplTest); |
| 40 runReflectiveTests(MethodElementImplTest); | 41 runReflectiveTests(MethodElementImplTest); |
| 41 runReflectiveTests(MultiplyDefinedElementImplTest); | 42 runReflectiveTests(MultiplyDefinedElementImplTest); |
| 42 runReflectiveTests(ParameterElementImplTest); | 43 runReflectiveTests(ParameterElementImplTest); |
| (...skipping 3720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3763 library.imports = expectedImports; | 3764 library.imports = expectedImports; |
| 3764 List<ImportElement> actualImports = library.imports; | 3765 List<ImportElement> actualImports = library.imports; |
| 3765 expect(actualImports, hasLength(expectedImports.length)); | 3766 expect(actualImports, hasLength(expectedImports.length)); |
| 3766 for (int i = 0; i < actualImports.length; i++) { | 3767 for (int i = 0; i < actualImports.length; i++) { |
| 3767 expect(actualImports[i], same(expectedImports[i])); | 3768 expect(actualImports[i], same(expectedImports[i])); |
| 3768 } | 3769 } |
| 3769 } | 3770 } |
| 3770 } | 3771 } |
| 3771 | 3772 |
| 3772 @reflectiveTest | 3773 @reflectiveTest |
| 3774 class LocalVariableElementImplTest extends EngineTestCase { |
| 3775 void test_computeNode_declaredIdentifier() { |
| 3776 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3777 AnalysisContext context = contextHelper.context; |
| 3778 Source source = contextHelper.addSource( |
| 3779 "/test.dart", |
| 3780 r''' |
| 3781 main() { |
| 3782 for (int v in <int>[1, 2, 3]) {} |
| 3783 }'''); |
| 3784 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3785 FunctionElement mainElement = libraryElement.units[0].functions[0]; |
| 3786 LocalVariableElement element = mainElement.localVariables[0]; |
| 3787 DeclaredIdentifier node = element.computeNode() as DeclaredIdentifier; |
| 3788 expect(node, isNotNull); |
| 3789 expect(node.identifier.name, 'v'); |
| 3790 expect(node.element, same(element)); |
| 3791 } |
| 3792 |
| 3793 void test_computeNode_variableDeclaration() { |
| 3794 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3795 AnalysisContext context = contextHelper.context; |
| 3796 Source source = contextHelper.addSource( |
| 3797 "/test.dart", |
| 3798 r''' |
| 3799 main() { |
| 3800 int v = 0; |
| 3801 }'''); |
| 3802 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3803 FunctionElement mainElement = libraryElement.units[0].functions[0]; |
| 3804 LocalVariableElement element = mainElement.localVariables[0]; |
| 3805 VariableDeclaration node = element.computeNode() as VariableDeclaration; |
| 3806 expect(node, isNotNull); |
| 3807 expect(node.name.name, 'v'); |
| 3808 expect(node.element, same(element)); |
| 3809 } |
| 3810 } |
| 3811 |
| 3812 @reflectiveTest |
| 3773 class MethodElementImplTest extends EngineTestCase { | 3813 class MethodElementImplTest extends EngineTestCase { |
| 3774 void test_computeNode() { | 3814 void test_computeNode() { |
| 3775 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 3815 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3776 AnalysisContext context = contextHelper.context; | 3816 AnalysisContext context = contextHelper.context; |
| 3777 Source source = contextHelper.addSource( | 3817 Source source = contextHelper.addSource( |
| 3778 "/test.dart", | 3818 "/test.dart", |
| 3779 r''' | 3819 r''' |
| 3780 abstract class A { | 3820 abstract class A { |
| 3781 String m1() => null; | 3821 String m1() => null; |
| 3782 m2(); | 3822 m2(); |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4188 } | 4228 } |
| 4189 | 4229 |
| 4190 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 4230 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
| 4191 extends InterfaceTypeImpl { | 4231 extends InterfaceTypeImpl { |
| 4192 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 4232 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
| 4193 : super(arg0); | 4233 : super(arg0); |
| 4194 | 4234 |
| 4195 @override | 4235 @override |
| 4196 bool get isDartCoreFunction => true; | 4236 bool get isDartCoreFunction => true; |
| 4197 } | 4237 } |
| OLD | NEW |