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/constant/value.dart'; | 8 import 'package:analyzer/dart/constant/value.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 3818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3829 library.imports = expectedImports; | 3829 library.imports = expectedImports; |
3830 List<ImportElement> actualImports = library.imports; | 3830 List<ImportElement> actualImports = library.imports; |
3831 expect(actualImports, hasLength(expectedImports.length)); | 3831 expect(actualImports, hasLength(expectedImports.length)); |
3832 for (int i = 0; i < actualImports.length; i++) { | 3832 for (int i = 0; i < actualImports.length; i++) { |
3833 expect(actualImports[i], same(expectedImports[i])); | 3833 expect(actualImports[i], same(expectedImports[i])); |
3834 } | 3834 } |
3835 } | 3835 } |
3836 } | 3836 } |
3837 | 3837 |
3838 @reflectiveTest | 3838 @reflectiveTest |
3839 class LocalVariableElementImplTest extends EngineTestCase { | 3839 class LocalVariableElementImplTest extends EngineTestCase {} |
3840 void test_computeNode_declaredIdentifier() { | |
3841 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | |
3842 AnalysisContext context = contextHelper.context; | |
3843 Source source = contextHelper.addSource( | |
3844 "/test.dart", | |
3845 r''' | |
3846 main() { | |
3847 for (int v in <int>[1, 2, 3]) {} | |
3848 }'''); | |
3849 LibraryElement libraryElement = context.computeLibraryElement(source); | |
3850 FunctionElement mainElement = libraryElement.units[0].functions[0]; | |
3851 LocalVariableElement element = mainElement.localVariables[0]; | |
3852 DeclaredIdentifier node = element.computeNode() as DeclaredIdentifier; | |
3853 expect(node, isNotNull); | |
3854 expect(node.identifier.name, 'v'); | |
3855 expect(node.element, same(element)); | |
3856 } | |
3857 | |
3858 void test_computeNode_variableDeclaration() { | |
3859 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | |
3860 AnalysisContext context = contextHelper.context; | |
3861 Source source = contextHelper.addSource( | |
3862 "/test.dart", | |
3863 r''' | |
3864 main() { | |
3865 int v = 0; | |
3866 }'''); | |
3867 LibraryElement libraryElement = context.computeLibraryElement(source); | |
3868 FunctionElement mainElement = libraryElement.units[0].functions[0]; | |
3869 LocalVariableElement element = mainElement.localVariables[0]; | |
3870 VariableDeclaration node = element.computeNode() as VariableDeclaration; | |
3871 expect(node, isNotNull); | |
3872 expect(node.name.name, 'v'); | |
3873 expect(node.element, same(element)); | |
3874 } | |
3875 } | |
3876 | 3840 |
3877 @reflectiveTest | 3841 @reflectiveTest |
3878 class MethodElementImplTest extends EngineTestCase { | 3842 class MethodElementImplTest extends EngineTestCase { |
3879 void test_computeNode() { | 3843 void test_computeNode() { |
3880 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); | 3844 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
3881 AnalysisContext context = contextHelper.context; | 3845 AnalysisContext context = contextHelper.context; |
3882 Source source = contextHelper.addSource( | 3846 Source source = contextHelper.addSource( |
3883 "/test.dart", | 3847 "/test.dart", |
3884 r''' | 3848 r''' |
3885 abstract class A { | 3849 abstract class A { |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4417 } | 4381 } |
4418 | 4382 |
4419 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 4383 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
4420 extends InterfaceTypeImpl { | 4384 extends InterfaceTypeImpl { |
4421 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 4385 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
4422 : super(arg0); | 4386 : super(arg0); |
4423 | 4387 |
4424 @override | 4388 @override |
4425 bool get isDartCoreFunction => true; | 4389 bool get isDartCoreFunction => true; |
4426 } | 4390 } |
OLD | NEW |