| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.element_test; | 8 library engine.element_test; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 runReflectiveTests(InterfaceTypeImplTest); | 30 runReflectiveTests(InterfaceTypeImplTest); |
| 31 runReflectiveTests(TypeParameterTypeImplTest); | 31 runReflectiveTests(TypeParameterTypeImplTest); |
| 32 runReflectiveTests(VoidTypeImplTest); | 32 runReflectiveTests(VoidTypeImplTest); |
| 33 runReflectiveTests(ClassElementImplTest); | 33 runReflectiveTests(ClassElementImplTest); |
| 34 runReflectiveTests(CompilationUnitElementImplTest); | 34 runReflectiveTests(CompilationUnitElementImplTest); |
| 35 runReflectiveTests(ElementLocationImplTest); | 35 runReflectiveTests(ElementLocationImplTest); |
| 36 runReflectiveTests(ElementImplTest); | 36 runReflectiveTests(ElementImplTest); |
| 37 runReflectiveTests(HtmlElementImplTest); | 37 runReflectiveTests(HtmlElementImplTest); |
| 38 runReflectiveTests(LibraryElementImplTest); | 38 runReflectiveTests(LibraryElementImplTest); |
| 39 runReflectiveTests(MultiplyDefinedElementImplTest); | 39 runReflectiveTests(MultiplyDefinedElementImplTest); |
| 40 runReflectiveTests(ParameterElementImplTest); |
| 40 } | 41 } |
| 41 | 42 |
| 42 @reflectiveTest | 43 @reflectiveTest |
| 43 class ClassElementImplTest extends EngineTestCase { | 44 class ClassElementImplTest extends EngineTestCase { |
| 44 void test_getAllSupertypes_interface() { | 45 void test_getAllSupertypes_interface() { |
| 45 ClassElement classA = ElementFactory.classElement2("A"); | 46 ClassElement classA = ElementFactory.classElement2("A"); |
| 46 ClassElement classB = ElementFactory.classElement("B", classA.type); | 47 ClassElement classB = ElementFactory.classElement("B", classA.type); |
| 47 ClassElementImpl elementC = ElementFactory.classElement2("C"); | 48 ClassElementImpl elementC = ElementFactory.classElement2("C"); |
| 48 InterfaceType typeObject = classA.supertype; | 49 InterfaceType typeObject = classA.supertype; |
| 49 InterfaceType typeA = classA.type; | 50 InterfaceType typeA = classA.type; |
| (...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2627 ClassElement classB = ElementFactory.classElement2("B", ["F", "G"]); | 2628 ClassElement classB = ElementFactory.classElement2("B", ["F", "G"]); |
| 2628 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); | 2629 InterfaceTypeImpl typeAF = new InterfaceTypeImpl.con1(classA); |
| 2629 typeAF.typeArguments = <DartType>[classB.typeParameters[0].type]; | 2630 typeAF.typeArguments = <DartType>[classB.typeParameters[0].type]; |
| 2630 InterfaceTypeImpl typeAG = new InterfaceTypeImpl.con1(classA); | 2631 InterfaceTypeImpl typeAG = new InterfaceTypeImpl.con1(classA); |
| 2631 typeAG.typeArguments = <DartType>[classB.typeParameters[1].type]; | 2632 typeAG.typeArguments = <DartType>[classB.typeParameters[1].type]; |
| 2632 expect(typeAG.isAssignableTo(typeAF), isFalse); | 2633 expect(typeAG.isAssignableTo(typeAF), isFalse); |
| 2633 } | 2634 } |
| 2634 | 2635 |
| 2635 void test_isAssignableTo_void() { | 2636 void test_isAssignableTo_void() { |
| 2636 InterfaceTypeImpl intType = _typeProvider.intType; | 2637 InterfaceTypeImpl intType = _typeProvider.intType; |
| 2637 expect( | 2638 expect(VoidTypeImpl.instance.isAssignableTo(intType), isFalse); |
| 2638 VoidTypeImpl.instance.isAssignableTo(intType), isFalse); | |
| 2639 } | 2639 } |
| 2640 | 2640 |
| 2641 void test_isDirectSupertypeOf_extends() { | 2641 void test_isDirectSupertypeOf_extends() { |
| 2642 ClassElement classA = ElementFactory.classElement2("A"); | 2642 ClassElement classA = ElementFactory.classElement2("A"); |
| 2643 ClassElement classB = ElementFactory.classElement("B", classA.type); | 2643 ClassElement classB = ElementFactory.classElement("B", classA.type); |
| 2644 InterfaceType typeA = classA.type; | 2644 InterfaceType typeA = classA.type; |
| 2645 InterfaceType typeB = classB.type; | 2645 InterfaceType typeB = classB.type; |
| 2646 expect(typeA.isDirectSupertypeOf(typeB), isTrue); | 2646 expect(typeA.isDirectSupertypeOf(typeB), isTrue); |
| 2647 } | 2647 } |
| 2648 | 2648 |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3617 } | 3617 } |
| 3618 | 3618 |
| 3619 void test_fromElements_nonConflicting() { | 3619 void test_fromElements_nonConflicting() { |
| 3620 Element element = ElementFactory.localVariableElement2("xx"); | 3620 Element element = ElementFactory.localVariableElement2("xx"); |
| 3621 expect(MultiplyDefinedElementImpl.fromElements(null, element, element), | 3621 expect(MultiplyDefinedElementImpl.fromElements(null, element, element), |
| 3622 same(element)); | 3622 same(element)); |
| 3623 } | 3623 } |
| 3624 } | 3624 } |
| 3625 | 3625 |
| 3626 @reflectiveTest | 3626 @reflectiveTest |
| 3627 class ParameterElementImplTest extends EngineTestCase { |
| 3628 void test_node_DefaultFormalParameter() { |
| 3629 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3630 AnalysisContext context = contextHelper.context; |
| 3631 Source source = contextHelper.addSource("/test.dart", r''' |
| 3632 main([int p = 42]) { |
| 3633 }'''); |
| 3634 // prepare CompilationUnitElement |
| 3635 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3636 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 3637 // p |
| 3638 { |
| 3639 ParameterElement element = unitElement.functions[0].parameters[0]; |
| 3640 DefaultFormalParameter node = element.node; |
| 3641 expect(node, isNotNull); |
| 3642 expect(node.identifier.name, 'p'); |
| 3643 expect(node.element, same(element)); |
| 3644 } |
| 3645 } |
| 3646 |
| 3647 void test_node_FieldFormalParameter() { |
| 3648 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3649 AnalysisContext context = contextHelper.context; |
| 3650 Source source = contextHelper.addSource("/test.dart", r''' |
| 3651 class A { |
| 3652 int p; |
| 3653 A(this.p) { |
| 3654 } |
| 3655 }'''); |
| 3656 // prepare CompilationUnitElement |
| 3657 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3658 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 3659 // p |
| 3660 { |
| 3661 ClassElement classA = unitElement.types[0]; |
| 3662 ConstructorElement constructorA = classA.constructors[0]; |
| 3663 FieldFormalParameterElement element = constructorA.parameters[0]; |
| 3664 FieldFormalParameter node = element.node; |
| 3665 expect(node, isNotNull); |
| 3666 expect(node.identifier.name, 'p'); |
| 3667 expect(node.element, same(element)); |
| 3668 } |
| 3669 } |
| 3670 |
| 3671 void test_node_FunctionTypedFormalParameter() { |
| 3672 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3673 AnalysisContext context = contextHelper.context; |
| 3674 Source source = contextHelper.addSource("/test.dart", r''' |
| 3675 main(p(int a, int b)) { |
| 3676 }'''); |
| 3677 // prepare CompilationUnitElement |
| 3678 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3679 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 3680 // p |
| 3681 { |
| 3682 ParameterElement element = unitElement.functions[0].parameters[0]; |
| 3683 FunctionTypedFormalParameter node = element.node; |
| 3684 expect(node, isNotNull); |
| 3685 expect(node.identifier.name, 'p'); |
| 3686 expect(node.element, same(element)); |
| 3687 } |
| 3688 } |
| 3689 |
| 3690 void test_node_SimpleFormalParameter() { |
| 3691 AnalysisContextHelper contextHelper = new AnalysisContextHelper(); |
| 3692 AnalysisContext context = contextHelper.context; |
| 3693 Source source = contextHelper.addSource("/test.dart", r''' |
| 3694 main(int p) { |
| 3695 }'''); |
| 3696 // prepare CompilationUnitElement |
| 3697 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3698 CompilationUnitElement unitElement = libraryElement.definingCompilationUnit; |
| 3699 // p |
| 3700 { |
| 3701 ParameterElement element = unitElement.functions[0].parameters[0]; |
| 3702 SimpleFormalParameter node = element.node; |
| 3703 expect(node, isNotNull); |
| 3704 expect(node.identifier.name, 'p'); |
| 3705 expect(node.element, same(element)); |
| 3706 } |
| 3707 } |
| 3708 } |
| 3709 |
| 3710 @reflectiveTest |
| 3627 class TypeParameterTypeImplTest extends EngineTestCase { | 3711 class TypeParameterTypeImplTest extends EngineTestCase { |
| 3628 void test_creation() { | 3712 void test_creation() { |
| 3629 expect(new TypeParameterTypeImpl( | 3713 expect(new TypeParameterTypeImpl( |
| 3630 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))), | 3714 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))), |
| 3631 isNotNull); | 3715 isNotNull); |
| 3632 } | 3716 } |
| 3633 | 3717 |
| 3634 void test_getElement() { | 3718 void test_getElement() { |
| 3635 TypeParameterElementImpl element = | 3719 TypeParameterElementImpl element = |
| 3636 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); | 3720 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3788 } | 3872 } |
| 3789 | 3873 |
| 3790 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 3874 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
| 3791 extends InterfaceTypeImpl { | 3875 extends InterfaceTypeImpl { |
| 3792 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 3876 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
| 3793 : super.con1(arg0); | 3877 : super.con1(arg0); |
| 3794 | 3878 |
| 3795 @override | 3879 @override |
| 3796 bool get isDartCoreFunction => true; | 3880 bool get isDartCoreFunction => true; |
| 3797 } | 3881 } |
| OLD | NEW |