Index: pkg/analyzer/test/src/context/source_test.dart |
diff --git a/pkg/analyzer/test/src/context/source_test.dart b/pkg/analyzer/test/src/context/source_test.dart |
index 7d63c4575bd95a37f8089c03b27f72569a68a4bc..83cf48471ee165582de14131a610d32d6e6e0923 100644 |
--- a/pkg/analyzer/test/src/context/source_test.dart |
+++ b/pkg/analyzer/test/src/context/source_test.dart |
@@ -2,10 +2,11 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-library analyzer.test.src.context.source_test; |
- |
import 'package:analyzer/file_system/file_system.dart'; |
+import 'package:analyzer/file_system/memory_file_system.dart'; |
import 'package:analyzer/src/context/source.dart'; |
+import 'package:analyzer/src/dart/sdk/sdk.dart'; |
+import 'package:analyzer/src/generated/java_engine_io.dart'; |
import 'package:analyzer/src/generated/source.dart'; |
import 'package:package_config/packages.dart'; |
import 'package:test/test.dart'; |
@@ -21,6 +22,17 @@ main() { |
@reflectiveTest |
class SourceFactoryImplTest extends AbstractContextTest { |
+ @soloTest |
+ void test_resolveUri_coreFromPart() { |
+ SourceFactoryImpl sourceFactory = new SourceFactoryImpl(<UriResolver>[ |
+ new ResourceUriResolver(resourceProvider), |
+ new DartUriResolver(_createDartSdk()) |
+ ]); |
+ Source coreSource = sourceFactory.forUri('dart:core'); |
+ Source numSource = sourceFactory.resolveUri(coreSource, 'num.dart'); |
+ expect(sourceFactory.resolveUri(numSource, 'core.dart'), coreSource); |
scheglov
2017/06/29 20:19:24
We test functionality of DartSdk, so it would be l
Brian Wilkerson
2017/06/29 20:47:15
Done
|
+ } |
+ |
void test_restoreUri() { |
String libPath = resourceProvider.convertPath('/pkgs/somepkg/lib/'); |
Uri libUri = resourceProvider.getFolder(libPath).toUri(); |
@@ -41,6 +53,68 @@ class SourceFactoryImplTest extends AbstractContextTest { |
rethrow; |
} |
} |
+ |
+ FolderBasedDartSdk _createDartSdk() { |
+ resourceProvider = new MemoryResourceProvider(); |
+ Folder sdkDirectory = |
+ resourceProvider.getFolder(resourceProvider.convertPath('/sdk')); |
+ _createFile(sdkDirectory, |
+ ['lib', '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart'], |
+ content: _librariesFileContent()); |
+ _createFile(sdkDirectory, ['bin', 'dart']); |
+ _createFile(sdkDirectory, ['bin', 'dart2js']); |
+ _createFile(sdkDirectory, ['bin', 'pub']); |
+ _createFile(sdkDirectory, ['lib', 'async', 'async.dart']); |
+ _createFile(sdkDirectory, ['lib', 'core', 'core.dart']); |
+ _createFile(sdkDirectory, ['lib', 'core', 'num.dart']); |
scheglov
2017/06/29 20:19:24
Hm... Why do we need all the rest if we use only c
|
+ _createFile(sdkDirectory, |
+ ['lib', 'html', 'html_common', 'html_common_dart2js.dart']); |
+ _createFile(sdkDirectory, ['lib', 'html', 'dartium', 'html_dartium.dart']); |
+ _createFile( |
+ sdkDirectory, ['bin', (OSUtilities.isWindows() ? 'pub.bat' : 'pub')]); |
+ return new FolderBasedDartSdk(resourceProvider, sdkDirectory); |
+ } |
+ |
+ void _createFile(Folder directory, List<String> segments, |
+ {String content: ''}) { |
+ Folder parent = directory; |
+ int last = segments.length - 1; |
+ for (int i = 0; i < last; i++) { |
+ parent = parent.getChildAssumingFolder(segments[i]); |
+ } |
+ File file = parent.getChildAssumingFile(segments[last]); |
+ resourceProvider.newFile(file.path, content); |
+ } |
+ |
+ String _librariesFileContent() => ''' |
+final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> { |
+ "async": const LibraryInfo( |
+ "async/async.dart", |
+ categories: "Client,Server", |
+ maturity: Maturity.STABLE, |
+ dart2jsPatchPath: "_internal/js_runtime/lib/async_patch.dart"), |
+ |
+ "core": const LibraryInfo( |
+ "core/core.dart", |
+ categories: "Client,Server,Embedded", |
+ maturity: Maturity.STABLE, |
+ dart2jsPatchPath: "_internal/js_runtime/lib/core_patch.dart"), |
+ |
+ "html": const LibraryInfo( |
+ "html/dartium/html_dartium.dart", |
+ categories: "Client", |
+ maturity: Maturity.WEB_STABLE, |
+ dart2jsPath: "html/dart2js/html_dart2js.dart"), |
+ |
+ "html_common": const LibraryInfo( |
+ "html/html_common/html_common.dart", |
+ categories: "Client", |
+ maturity: Maturity.WEB_STABLE, |
+ dart2jsPath: "html/html_common/html_common_dart2js.dart", |
+ documented: false, |
+ implementation: true), |
+}; |
+'''; |
} |
/** |