| 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'; |
| 11 import 'package:analyzer/src/dart/element/handle.dart'; |
| 11 import 'package:analyzer/src/dart/element/type.dart'; | 12 import 'package:analyzer/src/dart/element/type.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart' | 13 import 'package:analyzer/src/generated/engine.dart' |
| 13 show AnalysisContext, AnalysisOptionsImpl; | 14 show AnalysisContext, AnalysisOptionsImpl; |
| 14 import 'package:analyzer/src/generated/java_core.dart'; | 15 import 'package:analyzer/src/generated/java_core.dart'; |
| 15 import 'package:analyzer/src/generated/source_io.dart'; | 16 import 'package:analyzer/src/generated/source_io.dart'; |
| 16 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 17 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 17 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 18 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 18 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; | 19 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; |
| 19 import 'package:unittest/unittest.dart'; | 20 import 'package:unittest/unittest.dart'; |
| 20 | 21 |
| (...skipping 3675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3696 <LibraryElement>[library, libraryA, libraryAA, libraryB])); | 3697 <LibraryElement>[library, libraryA, libraryAA, libraryB])); |
| 3697 } | 3698 } |
| 3698 | 3699 |
| 3699 void test_getVisibleLibraries_noImports() { | 3700 void test_getVisibleLibraries_noImports() { |
| 3700 AnalysisContext context = createAnalysisContext(); | 3701 AnalysisContext context = createAnalysisContext(); |
| 3701 LibraryElementImpl library = ElementFactory.library(context, "app"); | 3702 LibraryElementImpl library = ElementFactory.library(context, "app"); |
| 3702 expect( | 3703 expect( |
| 3703 library.visibleLibraries, unorderedEquals(<LibraryElement>[library])); | 3704 library.visibleLibraries, unorderedEquals(<LibraryElement>[library])); |
| 3704 } | 3705 } |
| 3705 | 3706 |
| 3707 void test_invalidateLibraryCycles_withHandle() { |
| 3708 AnalysisContext context = createAnalysisContext(); |
| 3709 context.sourceFactory = new SourceFactory([]); |
| 3710 LibraryElementImpl library = ElementFactory.library(context, "foo"); |
| 3711 LibraryElementImpl importedLibrary = ElementFactory.library(context, "bar"); |
| 3712 ElementLocation location = new ElementLocationImpl.con2(''); |
| 3713 TestElementResynthesizer resynthesizer = |
| 3714 new TestElementResynthesizer(context, {location: importedLibrary}); |
| 3715 LibraryElement importedLibraryHandle = |
| 3716 new LibraryElementHandle(resynthesizer, location); |
| 3717 ImportElementImpl import = |
| 3718 ElementFactory.importFor(importedLibraryHandle, null); |
| 3719 library.imports = <ImportElement>[import]; |
| 3720 library.libraryCycle; // Force computation of the cycle. |
| 3721 |
| 3722 library.invalidateLibraryCycles(); |
| 3723 } |
| 3724 |
| 3706 void test_isUpToDate() { | 3725 void test_isUpToDate() { |
| 3707 AnalysisContext context = createAnalysisContext(); | 3726 AnalysisContext context = createAnalysisContext(); |
| 3708 context.sourceFactory = new SourceFactory([]); | 3727 context.sourceFactory = new SourceFactory([]); |
| 3709 LibraryElement library = ElementFactory.library(context, "foo"); | 3728 LibraryElement library = ElementFactory.library(context, "foo"); |
| 3710 context.setContents(library.definingCompilationUnit.source, "sdfsdff"); | 3729 context.setContents(library.definingCompilationUnit.source, "sdfsdff"); |
| 3711 // Assert that we are not up to date if the target has an old time stamp. | 3730 // Assert that we are not up to date if the target has an old time stamp. |
| 3712 expect(library.isUpToDate(0), isFalse); | 3731 expect(library.isUpToDate(0), isFalse); |
| 3713 // Assert that we are up to date with a target modification time in the | 3732 // Assert that we are up to date with a target modification time in the |
| 3714 // future. | 3733 // future. |
| 3715 expect(library.isUpToDate(JavaSystem.currentTimeMillis() + 1000), isTrue); | 3734 expect(library.isUpToDate(JavaSystem.currentTimeMillis() + 1000), isTrue); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3931 { | 3950 { |
| 3932 ParameterElement element = unitElement.functions[0].parameters[0]; | 3951 ParameterElement element = unitElement.functions[0].parameters[0]; |
| 3933 SimpleFormalParameter node = element.computeNode(); | 3952 SimpleFormalParameter node = element.computeNode(); |
| 3934 expect(node, isNotNull); | 3953 expect(node, isNotNull); |
| 3935 expect(node.identifier.name, 'p'); | 3954 expect(node.identifier.name, 'p'); |
| 3936 expect(node.element, same(element)); | 3955 expect(node.element, same(element)); |
| 3937 } | 3956 } |
| 3938 } | 3957 } |
| 3939 } | 3958 } |
| 3940 | 3959 |
| 3960 class TestElementResynthesizer extends ElementResynthesizer { |
| 3961 Map<ElementLocation, Element> locationMap; |
| 3962 |
| 3963 TestElementResynthesizer(AnalysisContext context, this.locationMap) |
| 3964 : super(context); |
| 3965 |
| 3966 @override |
| 3967 Element getElement(ElementLocation location) { |
| 3968 return locationMap[location]; |
| 3969 } |
| 3970 } |
| 3971 |
| 3941 @reflectiveTest | 3972 @reflectiveTest |
| 3942 class TypeParameterTypeImplTest extends EngineTestCase { | 3973 class TypeParameterTypeImplTest extends EngineTestCase { |
| 3943 void test_creation() { | 3974 void test_creation() { |
| 3944 expect( | 3975 expect( |
| 3945 new TypeParameterTypeImpl( | 3976 new TypeParameterTypeImpl( |
| 3946 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))), | 3977 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E"))), |
| 3947 isNotNull); | 3978 isNotNull); |
| 3948 } | 3979 } |
| 3949 | 3980 |
| 3950 void test_getElement() { | 3981 void test_getElement() { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4139 } | 4170 } |
| 4140 | 4171 |
| 4141 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 4172 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
| 4142 extends InterfaceTypeImpl { | 4173 extends InterfaceTypeImpl { |
| 4143 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 4174 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
| 4144 : super(arg0); | 4175 : super(arg0); |
| 4145 | 4176 |
| 4146 @override | 4177 @override |
| 4147 bool get isDartCoreFunction => true; | 4178 bool get isDartCoreFunction => true; |
| 4148 } | 4179 } |
| OLD | NEW |