| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.summary.prelinker_test; | 5 library analyzer.test.src.summary.prelinker_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/src/generated/source.dart'; | 8 import 'package:analyzer/src/generated/source.dart'; |
| 9 import 'package:analyzer/src/generated/source_io.dart'; | 9 import 'package:analyzer/src/generated/source_io.dart'; |
| 10 import 'package:analyzer/src/summary/idl.dart'; | 10 import 'package:analyzer/src/summary/idl.dart'; |
| 11 import 'package:analyzer/src/summary/prelink.dart'; | 11 import 'package:analyzer/src/summary/prelink.dart'; |
| 12 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 12 import 'package:unittest/unittest.dart'; | 13 import 'package:unittest/unittest.dart'; |
| 13 | 14 |
| 14 import '../../reflective_tests.dart'; | |
| 15 import 'summarize_elements_test.dart'; | 15 import 'summarize_elements_test.dart'; |
| 16 import 'summary_common.dart'; | 16 import 'summary_common.dart'; |
| 17 | 17 |
| 18 main() { | 18 main() { |
| 19 groupSep = ' | '; | 19 groupSep = ' | '; |
| 20 runReflectiveTests(PrelinkerTest); | 20 defineReflectiveTests(PrelinkerTest); |
| 21 } | 21 } |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Override of [SummaryTest] which verifies the correctness of the prelinker by | 24 * Override of [SummaryTest] which verifies the correctness of the prelinker by |
| 25 * creating summaries from the element model, discarding their prelinked | 25 * creating summaries from the element model, discarding their prelinked |
| 26 * information, and then recreating it using the prelinker. | 26 * information, and then recreating it using the prelinker. |
| 27 */ | 27 */ |
| 28 @reflectiveTest | 28 @reflectiveTest |
| 29 class PrelinkerTest extends SummarizeElementsTest { | 29 class PrelinkerTest extends SummarizeElementsTest { |
| 30 final Map<String, UnlinkedPublicNamespace> uriToPublicNamespace = | 30 final Map<String, UnlinkedPublicNamespace> uriToPublicNamespace = |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 } | 68 } |
| 69 UnlinkedUnit getPart(String relativeUri) { | 69 UnlinkedUnit getPart(String relativeUri) { |
| 70 String absoluteUri = resolveToAbsoluteUri(library, relativeUri); | 70 String absoluteUri = resolveToAbsoluteUri(library, relativeUri); |
| 71 UnlinkedUnit unit = uriToUnit[absoluteUri]; | 71 UnlinkedUnit unit = uriToUnit[absoluteUri]; |
| 72 if (unit == null) { | 72 if (unit == null) { |
| 73 fail('Prelinker unexpectedly requested unit for "$relativeUri"' | 73 fail('Prelinker unexpectedly requested unit for "$relativeUri"' |
| 74 ' (resolves to "$absoluteUri").'); | 74 ' (resolves to "$absoluteUri").'); |
| 75 } | 75 } |
| 76 return unit; | 76 return unit; |
| 77 } | 77 } |
| 78 |
| 78 UnlinkedPublicNamespace getImport(String relativeUri) { | 79 UnlinkedPublicNamespace getImport(String relativeUri) { |
| 79 String absoluteUri = resolveToAbsoluteUri(library, relativeUri); | 80 String absoluteUri = resolveToAbsoluteUri(library, relativeUri); |
| 80 UnlinkedPublicNamespace namespace = SerializedMockSdk | 81 UnlinkedPublicNamespace namespace = SerializedMockSdk |
| 81 .instance.uriToUnlinkedUnit[absoluteUri]?.publicNamespace; | 82 .instance.uriToUnlinkedUnit[absoluteUri]?.publicNamespace; |
| 82 if (namespace == null) { | 83 if (namespace == null) { |
| 83 namespace = uriToPublicNamespace[absoluteUri]; | 84 namespace = uriToPublicNamespace[absoluteUri]; |
| 84 } | 85 } |
| 85 if (namespace == null && !allowMissingFiles) { | 86 if (namespace == null && !allowMissingFiles) { |
| 86 fail('Prelinker unexpectedly requested namespace for "$relativeUri"' | 87 fail('Prelinker unexpectedly requested namespace for "$relativeUri"' |
| 87 ' (resolves to "$absoluteUri").' | 88 ' (resolves to "$absoluteUri").' |
| 88 ' Namespaces available: ${uriToPublicNamespace.keys}'); | 89 ' Namespaces available: ${uriToPublicNamespace.keys}'); |
| 89 } | 90 } |
| 90 return namespace; | 91 return namespace; |
| 91 } | 92 } |
| 93 |
| 92 linked = new LinkedLibrary.fromBuffer( | 94 linked = new LinkedLibrary.fromBuffer( |
| 93 prelink(unlinkedUnits[0], getPart, getImport).toBuffer()); | 95 prelink(unlinkedUnits[0], getPart, getImport).toBuffer()); |
| 94 validateLinkedLibrary(linked); | 96 validateLinkedLibrary(linked); |
| 95 } | 97 } |
| 96 } | 98 } |
| OLD | NEW |