| 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 22 matching lines...) Expand all Loading... |
| 33 defineReflectiveTests(InterfaceTypeImplTest); | 33 defineReflectiveTests(InterfaceTypeImplTest); |
| 34 defineReflectiveTests(LocalVariableElementImplTest); | 34 defineReflectiveTests(LocalVariableElementImplTest); |
| 35 defineReflectiveTests(TypeParameterTypeImplTest); | 35 defineReflectiveTests(TypeParameterTypeImplTest); |
| 36 defineReflectiveTests(VoidTypeImplTest); | 36 defineReflectiveTests(VoidTypeImplTest); |
| 37 defineReflectiveTests(ClassElementImplTest); | 37 defineReflectiveTests(ClassElementImplTest); |
| 38 defineReflectiveTests(CompilationUnitElementImplTest); | 38 defineReflectiveTests(CompilationUnitElementImplTest); |
| 39 defineReflectiveTests(ElementLocationImplTest); | 39 defineReflectiveTests(ElementLocationImplTest); |
| 40 defineReflectiveTests(ElementImplTest); | 40 defineReflectiveTests(ElementImplTest); |
| 41 defineReflectiveTests(LibraryElementImplTest); | 41 defineReflectiveTests(LibraryElementImplTest); |
| 42 defineReflectiveTests(MethodElementImplTest); | 42 defineReflectiveTests(MethodElementImplTest); |
| 43 defineReflectiveTests(MethodMemberTest); |
| 43 defineReflectiveTests(MultiplyDefinedElementImplTest); | 44 defineReflectiveTests(MultiplyDefinedElementImplTest); |
| 44 defineReflectiveTests(ParameterElementImplTest); | 45 defineReflectiveTests(ParameterElementImplTest); |
| 45 defineReflectiveTests(PropertyAccessorElementImplTest); | 46 defineReflectiveTests(PropertyAccessorElementImplTest); |
| 46 defineReflectiveTests(TopLevelVariableElementImplTest); | 47 defineReflectiveTests(TopLevelVariableElementImplTest); |
| 47 }); | 48 }); |
| 48 } | 49 } |
| 49 | 50 |
| 50 @reflectiveTest | 51 @reflectiveTest |
| 51 class ClassElementImplTest extends EngineTestCase { | 52 class ClassElementImplTest extends EngineTestCase { |
| 52 void test_computeNode_ClassDeclaration() { | 53 void test_computeNode_ClassDeclaration() { |
| (...skipping 3954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4007 MethodElement m2Element = unitElement.getType("A").getMethod('m2'); | 4008 MethodElement m2Element = unitElement.getType("A").getMethod('m2'); |
| 4008 MethodDeclaration m2Node = m2Element.computeNode(); | 4009 MethodDeclaration m2Node = m2Element.computeNode(); |
| 4009 expect(m2Node, isNotNull); | 4010 expect(m2Node, isNotNull); |
| 4010 expect(m2Node.name.name, "m2"); | 4011 expect(m2Node.name.name, "m2"); |
| 4011 expect(m2Node.element, same(m2Element)); | 4012 expect(m2Node.element, same(m2Element)); |
| 4012 } | 4013 } |
| 4013 } | 4014 } |
| 4014 } | 4015 } |
| 4015 | 4016 |
| 4016 @reflectiveTest | 4017 @reflectiveTest |
| 4018 class MethodMemberTest extends EngineTestCase { |
| 4019 /** |
| 4020 * The type provider used to access the types. |
| 4021 */ |
| 4022 TestTypeProvider _typeProvider; |
| 4023 |
| 4024 @override |
| 4025 void setUp() { |
| 4026 super.setUp(); |
| 4027 _typeProvider = new TestTypeProvider(); |
| 4028 } |
| 4029 |
| 4030 void test_getReifiedType_substituteFor() { |
| 4031 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 4032 options.analyzeFunctionBodies = false; |
| 4033 AnalysisContextHelper contextHelper = new AnalysisContextHelper(options); |
| 4034 AnalysisContext context = contextHelper.context; |
| 4035 Source source = contextHelper.addSource( |
| 4036 "/test.dart", |
| 4037 r''' |
| 4038 class A<T> { |
| 4039 T f(T x) => x; |
| 4040 } |
| 4041 class B<S> extends A<S> { |
| 4042 S f(S x) => x; |
| 4043 } |
| 4044 '''); |
| 4045 // prepare CompilationUnitElement |
| 4046 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 4047 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 4048 DartType objectType = _typeProvider.objectType; |
| 4049 // B.f |
| 4050 ClassElement elementB = unitElement.getType("B"); |
| 4051 MethodElement BfElement = elementB.type |
| 4052 .lookUpInheritedMethod("f", library: libraryElement, thisType: true); |
| 4053 MethodElement AfElement = elementB.type |
| 4054 .lookUpInheritedMethod("f", library: libraryElement, thisType: false); |
| 4055 expect(BfElement.getReifiedType(objectType), |
| 4056 equals(AfElement.getReifiedType(objectType))); |
| 4057 } |
| 4058 } |
| 4059 |
| 4060 @reflectiveTest |
| 4017 class MultiplyDefinedElementImplTest extends EngineTestCase { | 4061 class MultiplyDefinedElementImplTest extends EngineTestCase { |
| 4018 void test_fromElements_conflicting() { | 4062 void test_fromElements_conflicting() { |
| 4019 TopLevelVariableElement firstElement = | 4063 TopLevelVariableElement firstElement = |
| 4020 ElementFactory.topLevelVariableElement2('xx'); | 4064 ElementFactory.topLevelVariableElement2('xx'); |
| 4021 TopLevelVariableElement secondElement = | 4065 TopLevelVariableElement secondElement = |
| 4022 ElementFactory.topLevelVariableElement2('yy'); | 4066 ElementFactory.topLevelVariableElement2('yy'); |
| 4023 _addToLibrary([firstElement, secondElement]); | 4067 _addToLibrary([firstElement, secondElement]); |
| 4024 Element result = MultiplyDefinedElementImpl.fromElements( | 4068 Element result = MultiplyDefinedElementImpl.fromElements( |
| 4025 null, firstElement, secondElement); | 4069 null, firstElement, secondElement); |
| 4026 EngineTestCase.assertInstanceOf( | 4070 EngineTestCase.assertInstanceOf( |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4444 } | 4488 } |
| 4445 | 4489 |
| 4446 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 4490 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
| 4447 extends InterfaceTypeImpl { | 4491 extends InterfaceTypeImpl { |
| 4448 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 4492 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
| 4449 : super(arg0); | 4493 : super(arg0); |
| 4450 | 4494 |
| 4451 @override | 4495 @override |
| 4452 bool get isDartCoreFunction => true; | 4496 bool get isDartCoreFunction => true; |
| 4453 } | 4497 } |
| OLD | NEW |