Chromium Code Reviews| Index: pkg/analyzer/test/src/dart/sdk/sdk_test.dart |
| diff --git a/pkg/analyzer/test/src/dart/sdk/sdk_test.dart b/pkg/analyzer/test/src/dart/sdk/sdk_test.dart |
| index 882f08b4005c66ea630f8910035fdfac6ebbc578..f4e78b94f8ec40783be6afebd3a7fc401adf5da0 100644 |
| --- a/pkg/analyzer/test/src/dart/sdk/sdk_test.dart |
| +++ b/pkg/analyzer/test/src/dart/sdk/sdk_test.dart |
| @@ -25,7 +25,8 @@ main() { |
| defineReflectiveTests(EmbedderSdkTest); |
| defineReflectiveTests(FolderBasedDartSdkTest); |
| defineReflectiveTests(SdkExtensionFinderTest); |
| - defineReflectiveTests(SDKLibrariesReaderTest); |
| + defineReflectiveTests(SdkLibrariesReaderTest); |
| + defineReflectiveTests(SdkLibraryImplTest); |
| }); |
| } |
| @@ -391,7 +392,7 @@ class SdkExtensionFinderTest { |
| } |
| @reflectiveTest |
| -class SDKLibrariesReaderTest extends EngineTestCase { |
| +class SdkLibrariesReaderTest extends EngineTestCase { |
| /** |
| * The resource provider used by these tests. |
| */ |
| @@ -473,4 +474,79 @@ final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> { |
| expect(second.isImplementation, true); |
| expect(second.isVmLibrary, false); |
| } |
| + |
| + void test_readFrom_patches() { |
| + LibraryMap libraryMap = new SdkLibrariesReader(false).readFromFile( |
| + resourceProvider.getFile('/libs.dart'), |
| + r''' |
| +final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> { |
| + 'foo' : const LibraryInfo( |
| + 'foo/foo.dart', |
| + patches: { |
| + VM_PLATFORM: 'foo/foo_vm_patch.dart', |
|
Paul Berry
2016/10/10 19:14:38
Since "patches" should be a Map<int, List<String>>
scheglov
2016/10/10 19:41:52
Done.
|
| + VM_PLATFORM: 'foo/bar_vm_patch.dart', |
| + DART2JS_PLATFORM: '_internal/js_runtime/lib/foo_patch.dart'}, |
| + maturity: Maturity.STABLE), |
| +};'''); |
| + expect(libraryMap, isNotNull); |
| + expect(libraryMap.size(), 1); |
| + SdkLibrary library = libraryMap.getLibrary('dart:foo'); |
| + expect(library, isNotNull); |
| + expect(library.path, 'foo/foo.dart'); |
| + expect(library.shortName, 'dart:foo'); |
| + expect(library.getPatches(SdkLibraryImpl.VM_PLATFORM), |
| + unorderedEquals(['foo/foo_vm_patch.dart', 'foo/bar_vm_patch.dart'])); |
| + expect(library.getPatches(SdkLibraryImpl.DART2JS_PLATFORM), |
| + unorderedEquals(['_internal/js_runtime/lib/foo_patch.dart'])); |
| + } |
| + |
| + void test_readFrom_patches_invalid_unknownPlatform() { |
| + expect(() { |
| + new SdkLibrariesReader(false).readFromFile( |
| + resourceProvider.getFile('/libs.dart'), |
| + r''' |
| +final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> { |
| + 'foo' : const LibraryInfo( |
| + 'foo/foo.dart', |
| + patches: { |
| + MY_UNKNOWN_PLATFORM: 'foo/bar_patch.dart'}), |
| +};'''); |
| + }, throwsArgumentError); |
| + } |
| + |
| + void test_readFrom_patches_no() { |
| + LibraryMap libraryMap = new SdkLibrariesReader(false).readFromFile( |
| + resourceProvider.getFile('/libs.dart'), |
| + r''' |
| +final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> { |
| + 'my' : const LibraryInfo('my/my.dart') |
| +};'''); |
| + expect(libraryMap, isNotNull); |
| + expect(libraryMap.size(), 1); |
| + SdkLibrary library = libraryMap.getLibrary('dart:my'); |
| + expect(library, isNotNull); |
| + expect(library.path, 'my/my.dart'); |
| + expect(library.shortName, 'dart:my'); |
| + expect(library.getPatches(SdkLibraryImpl.VM_PLATFORM), isEmpty); |
| + expect(library.getPatches(SdkLibraryImpl.DART2JS_PLATFORM), isEmpty); |
| + } |
| +} |
| + |
| +@reflectiveTest |
| +class SdkLibraryImplTest extends EngineTestCase { |
| + void test_patches() { |
| + SdkLibraryImpl library = new SdkLibraryImpl('dart:async'); |
| + // Add patches. |
| + library.addPatch(SdkLibraryImpl.VM_PLATFORM, 'async/async_vm_patch.dart'); |
| + library.addPatch(SdkLibraryImpl.VM_PLATFORM, 'async/timer_vm_patch.dart'); |
| + library.addPatch(SdkLibraryImpl.DART2JS_PLATFORM, |
| + '_internal/js_runtime/lib/async_patch.dart'); |
| + // Get patches. |
| + expect( |
| + library.getPatches(SdkLibraryImpl.VM_PLATFORM), |
| + unorderedEquals( |
| + ['async/async_vm_patch.dart', 'async/timer_vm_patch.dart'])); |
| + expect(library.getPatches(SdkLibraryImpl.DART2JS_PLATFORM), |
| + unorderedEquals(['_internal/js_runtime/lib/async_patch.dart'])); |
| + } |
| } |