| 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 3917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3928 LibraryElement importedLibraryHandle = | 3928 LibraryElement importedLibraryHandle = |
| 3929 new LibraryElementHandle(resynthesizer, location); | 3929 new LibraryElementHandle(resynthesizer, location); |
| 3930 ImportElementImpl import = | 3930 ImportElementImpl import = |
| 3931 ElementFactory.importFor(importedLibraryHandle, null); | 3931 ElementFactory.importFor(importedLibraryHandle, null); |
| 3932 library.imports = <ImportElement>[import]; | 3932 library.imports = <ImportElement>[import]; |
| 3933 library.libraryCycle; // Force computation of the cycle. | 3933 library.libraryCycle; // Force computation of the cycle. |
| 3934 | 3934 |
| 3935 library.invalidateLibraryCycles(); | 3935 library.invalidateLibraryCycles(); |
| 3936 } | 3936 } |
| 3937 | 3937 |
| 3938 void test_isUpToDate() { | |
| 3939 AnalysisContext context = createAnalysisContext(); | |
| 3940 context.sourceFactory = new SourceFactory([]); | |
| 3941 LibraryElement library = ElementFactory.library(context, "foo"); | |
| 3942 context.setContents(library.definingCompilationUnit.source, "sdfsdff"); | |
| 3943 // Assert that we are not up to date if the target has an old time stamp. | |
| 3944 expect(library.isUpToDate(-1), isFalse); | |
| 3945 // Assert that we are up to date with a target modification time in the | |
| 3946 // future. | |
| 3947 expect(library.isUpToDate(1 << 33), isTrue); | |
| 3948 } | |
| 3949 | |
| 3950 void test_setImports() { | 3938 void test_setImports() { |
| 3951 AnalysisContext context = createAnalysisContext(); | 3939 AnalysisContext context = createAnalysisContext(); |
| 3952 LibraryElementImpl library = new LibraryElementImpl.forNode( | 3940 LibraryElementImpl library = new LibraryElementImpl.forNode( |
| 3953 context, AstFactory.libraryIdentifier2(["l1"])); | 3941 context, AstFactory.libraryIdentifier2(["l1"])); |
| 3954 List<ImportElementImpl> expectedImports = [ | 3942 List<ImportElementImpl> expectedImports = [ |
| 3955 ElementFactory.importFor(ElementFactory.library(context, "l2"), null), | 3943 ElementFactory.importFor(ElementFactory.library(context, "l2"), null), |
| 3956 ElementFactory.importFor(ElementFactory.library(context, "l3"), null) | 3944 ElementFactory.importFor(ElementFactory.library(context, "l3"), null) |
| 3957 ]; | 3945 ]; |
| 3958 library.imports = expectedImports; | 3946 library.imports = expectedImports; |
| 3959 List<ImportElement> actualImports = library.imports; | 3947 List<ImportElement> actualImports = library.imports; |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4327 } | 4315 } |
| 4328 | 4316 |
| 4329 void test_isMoreSpecificThan_typeArguments_object() { | 4317 void test_isMoreSpecificThan_typeArguments_object() { |
| 4330 TypeParameterElementImpl element = | 4318 TypeParameterElementImpl element = |
| 4331 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); | 4319 new TypeParameterElementImpl.forNode(AstFactory.identifier3("E")); |
| 4332 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); | 4320 TypeParameterTypeImpl type = new TypeParameterTypeImpl(element); |
| 4333 // E << Object | 4321 // E << Object |
| 4334 expect(type.isMoreSpecificThan(ElementFactory.object.type), isTrue); | 4322 expect(type.isMoreSpecificThan(ElementFactory.object.type), isTrue); |
| 4335 } | 4323 } |
| 4336 | 4324 |
| 4337 void test_isMoreSpecificThan_typeArguments_resursive() { | 4325 void test_isMoreSpecificThan_typeArguments_recursive() { |
| 4338 ClassElementImpl classS = ElementFactory.classElement2("A"); | 4326 ClassElementImpl classS = ElementFactory.classElement2("A"); |
| 4339 TypeParameterElementImpl typeParameterU = | 4327 TypeParameterElementImpl typeParameterU = |
| 4340 new TypeParameterElementImpl.forNode(AstFactory.identifier3("U")); | 4328 new TypeParameterElementImpl.forNode(AstFactory.identifier3("U")); |
| 4341 TypeParameterTypeImpl typeParameterTypeU = | 4329 TypeParameterTypeImpl typeParameterTypeU = |
| 4342 new TypeParameterTypeImpl(typeParameterU); | 4330 new TypeParameterTypeImpl(typeParameterU); |
| 4343 TypeParameterElementImpl typeParameterT = | 4331 TypeParameterElementImpl typeParameterT = |
| 4344 new TypeParameterElementImpl.forNode(AstFactory.identifier3("T")); | 4332 new TypeParameterElementImpl.forNode(AstFactory.identifier3("T")); |
| 4345 TypeParameterTypeImpl typeParameterTypeT = | 4333 TypeParameterTypeImpl typeParameterTypeT = |
| 4346 new TypeParameterTypeImpl(typeParameterT); | 4334 new TypeParameterTypeImpl(typeParameterT); |
| 4347 typeParameterT.bound = typeParameterTypeU; | 4335 typeParameterT.bound = typeParameterTypeU; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4503 } | 4491 } |
| 4504 | 4492 |
| 4505 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction | 4493 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction |
| 4506 extends InterfaceTypeImpl { | 4494 extends InterfaceTypeImpl { |
| 4507 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) | 4495 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) |
| 4508 : super(arg0); | 4496 : super(arg0); |
| 4509 | 4497 |
| 4510 @override | 4498 @override |
| 4511 bool get isDartCoreFunction => true; | 4499 bool get isDartCoreFunction => true; |
| 4512 } | 4500 } |
| OLD | NEW |