| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 engine.declaration_resolver_test; | 5 library engine.declaration_resolver_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/src/dart/ast/ast.dart'; | 9 import 'package:analyzer/src/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/src/dart/ast/utilities.dart'; | 10 import 'package:analyzer/src/dart/ast/utilities.dart'; |
| 11 import 'package:analyzer/src/generated/engine.dart'; | 11 import 'package:analyzer/src/generated/engine.dart'; |
| 12 import 'package:analyzer/src/generated/resolver.dart'; | 12 import 'package:analyzer/src/generated/resolver.dart'; |
| 13 import 'package:analyzer/src/generated/source.dart'; |
| 14 import 'package:analyzer/src/task/dart.dart'; |
| 15 import 'package:analyzer/task/dart.dart'; |
| 13 import 'package:unittest/unittest.dart'; | 16 import 'package:unittest/unittest.dart'; |
| 14 | 17 |
| 15 import '../reflective_tests.dart'; | 18 import '../reflective_tests.dart'; |
| 16 import '../utils.dart'; | 19 import '../utils.dart'; |
| 17 import 'resolver_test.dart'; | 20 import 'resolver_test.dart'; |
| 18 import 'test_support.dart'; | 21 import 'test_support.dart'; |
| 19 | 22 |
| 20 main() { | 23 main() { |
| 21 initializeTestEnvironment(); | 24 initializeTestEnvironment(); |
| 22 runReflectiveTests(DeclarationResolverMetadataTest); | 25 runReflectiveTests(DeclarationResolverMetadataTest); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 setupCode('f([@a g() = null]) {}'); | 141 setupCode('f([@a g() = null]) {}'); |
| 139 checkMetadata('g'); | 142 checkMetadata('g'); |
| 140 } | 143 } |
| 141 | 144 |
| 142 void test_metadata_importDirective() { | 145 void test_metadata_importDirective() { |
| 143 addNamedSource('/foo.dart', 'class C {}'); | 146 addNamedSource('/foo.dart', 'class C {}'); |
| 144 setupCode('@a import "foo.dart";'); | 147 setupCode('@a import "foo.dart";'); |
| 145 checkMetadata('import'); | 148 checkMetadata('import'); |
| 146 } | 149 } |
| 147 | 150 |
| 151 void test_metadata_importDirective_partiallyResolved() { |
| 152 addNamedSource('/foo.dart', 'class C {}'); |
| 153 this.code = 'const a = null; @a import "foo.dart";'; |
| 154 Source source = addNamedSource('/test.dart', code); |
| 155 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
| 156 analysisContext.computeResult(source, LIBRARY_ELEMENT1); |
| 157 unit = analysisContext.computeResult(target, RESOLVED_UNIT1); |
| 158 unit2 = _cloneResolveUnit(unit); |
| 159 checkMetadata('import'); |
| 160 } |
| 161 |
| 148 void test_metadata_libraryDirective() { | 162 void test_metadata_libraryDirective() { |
| 149 setupCode('@a library L;'); | 163 setupCode('@a library L;'); |
| 150 checkMetadata('L'); | 164 checkMetadata('L'); |
| 151 } | 165 } |
| 152 | 166 |
| 153 void test_metadata_localFunctionDeclaration() { | 167 void test_metadata_localFunctionDeclaration() { |
| 154 setupCode('f() { @a g() {} }'); | 168 setupCode('f() { @a g() {} }'); |
| 155 // Note: metadata on local function declarations is ignored by the | 169 // Note: metadata on local function declarations is ignored by the |
| 156 // analyzer. TODO(paulberry): is this a bug? | 170 // analyzer. TODO(paulberry): is this a bug? |
| 157 FunctionDeclaration node = EngineTestCase.findNode( | 171 FunctionDeclaration node = EngineTestCase.findNode( |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 expect(element.type.toString(), "<T>(T, T) → T"); | 524 expect(element.type.toString(), "<T>(T, T) → T"); |
| 511 expect(t.element, same(tElement)); | 525 expect(t.element, same(tElement)); |
| 512 | 526 |
| 513 // re-resolve | 527 // re-resolve |
| 514 CompilationUnit unit2 = _cloneResolveUnit(unit); | 528 CompilationUnit unit2 = _cloneResolveUnit(unit); |
| 515 node = _findSimpleIdentifier(unit2, code, 'max').parent; | 529 node = _findSimpleIdentifier(unit2, code, 'max').parent; |
| 516 t = node.typeParameters.typeParameters[0]; | 530 t = node.typeParameters.typeParameters[0]; |
| 517 expect(t.element, same(tElement)); | 531 expect(t.element, same(tElement)); |
| 518 } | 532 } |
| 519 } | 533 } |
| OLD | NEW |