Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: pkg/analyzer/test/src/context/context_factory_test.dart

Issue 2046493006: Package map processing tests. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/test_all.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/context/context_factory_test.dart
diff --git a/pkg/analyzer/test/src/context/context_factory_test.dart b/pkg/analyzer/test/src/context/context_factory_test.dart
index fff9681af8e4a5434f03720b608905c749efdf05..a116d292382eef3e6c75a44c37f0b4f54c183b8a 100644
--- a/pkg/analyzer/test/src/context/context_factory_test.dart
+++ b/pkg/analyzer/test/src/context/context_factory_test.dart
@@ -19,17 +19,24 @@ main() {
@reflectiveTest
class PackageMapProcessorTest {
- static MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
+ MemoryResourceProvider resourceProvider;
- static Folder empty = resourceProvider.newFolder('/empty');
- static Folder tmp_sdk_ext = resourceProvider.newFolder('/tmp_sdk_ext');
- static Folder tmp_embedder = resourceProvider.newFolder('/tmp_embedder');
+ Folder empty;
+ Folder tmp_sdk_ext;
+ Folder tmp_embedder;
+ Map<String, List<Folder>> packageMap;
- static Map<String, List<Folder>> packageMap = <String, List<Folder>>{
- 'empty': [empty],
- 'tmp_embedder': [tmp_embedder],
- 'tmp_sdk_ext': [tmp_sdk_ext]
- };
+ void setUp() {
+ resourceProvider = new MemoryResourceProvider();
+ empty = resourceProvider.newFolder('/empty');
+ tmp_sdk_ext = resourceProvider.newFolder('/tmp_sdk_ext');
+ tmp_embedder = resourceProvider.newFolder('/tmp_embedder');
+ packageMap = <String, List<Folder>>{
+ 'empty': [empty],
+ 'tmp_embedder': [tmp_embedder],
+ 'tmp_sdk_ext': [tmp_sdk_ext]
+ };
+ }
void test_basic_processing() {
resourceProvider.newFile(
@@ -51,7 +58,19 @@ embedded_libs:
PackageMapProcessor proc = new PackageMapProcessor(packageMap);
expect(proc.embeddedLibraries.size(), 5);
+ expect(proc.embeddedLibraries.getLibrary('dart:core').path,
+ '/tmp_embedder/core.dart');
expect(proc.extendedLibraries.size(), 1);
+ expect(proc.extendedLibraries.getLibrary('dart:ui').path,
+ '/tmp_sdk_ext/ui.dart');
+ }
+
+ void test_empty_package_map() {
+ PackageMapProcessor proc =
+ new PackageMapProcessor(<String, List<Folder>>{});
+ expect(proc.embeddedLibraries.size(), 0);
+ expect(proc.extendedLibraries.size(), 0);
+ expect(proc.libraryMap.size(), 0);
}
void test_extenders_do_not_override() {
@@ -75,4 +94,66 @@ embedded_libs:
expect(proc.libraryMap.size(), 2);
expect(proc.libraryMap.getLibrary('dart:ui').path, '/tmp_embedder/ui.dart');
}
+
+ void test_invalid_embedder() {
+ resourceProvider.newFile(
+ '/tmp_embedder/_embedder.yaml',
+ r'''
+invalid contents, will not parse
+''');
+
+ PackageMapProcessor proc = new PackageMapProcessor(packageMap);
+ expect(proc.embeddedLibraries.size(), 0);
+ expect(proc.extendedLibraries.size(), 0);
+ expect(proc.libraryMap.size(), 0);
+ }
+
+ void test_invalid_extender() {
+ resourceProvider.newFile(
+ '/tmp_sdk_ext/_sdkext',
+ r'''
+invalid contents, will not parse
+''');
+
+ PackageMapProcessor proc = new PackageMapProcessor(packageMap);
+ expect(proc.embeddedLibraries.size(), 0);
+ expect(proc.extendedLibraries.size(), 0);
+ expect(proc.libraryMap.size(), 0);
+ }
+
+ void test_no_embedder() {
+ resourceProvider.newFile(
+ '/tmp_sdk_ext/_sdkext',
+ r'''
+ {
+ "dart:ui": "ui2.dart"
+ }''');
+
+ PackageMapProcessor proc = new PackageMapProcessor(packageMap);
+ expect(proc.embeddedLibraries.size(), 0);
+ expect(proc.extendedLibraries.size(), 1);
+ expect(proc.libraryMap.size(), 1);
+ }
+
+ void test_no_embedder_or_extender() {
+ PackageMapProcessor proc = new PackageMapProcessor(packageMap);
+ expect(proc.embeddedLibraries.size(), 0);
+ expect(proc.extendedLibraries.size(), 0);
+ expect(proc.libraryMap.size(), 0);
+ }
+
+ void test_no_extender() {
+ resourceProvider.newFile(
+ '/tmp_embedder/_embedder.yaml',
+ r'''
+embedded_libs:
+ "dart:core" : "core.dart"
+ "dart:ui": "ui.dart"
+''');
+
+ PackageMapProcessor proc = new PackageMapProcessor(packageMap);
+ expect(proc.embeddedLibraries.size(), 2);
+ expect(proc.extendedLibraries.size(), 0);
+ expect(proc.libraryMap.size(), 2);
+ }
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698