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

Unified Diff: pkg/analyzer/test/src/dart/sdk/patch_test.dart

Issue 2414123003: Add support for patching parts. (Closed)
Patch Set: Created 4 years, 2 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
Index: pkg/analyzer/test/src/dart/sdk/patch_test.dart
diff --git a/pkg/analyzer/test/src/dart/sdk/patch_test.dart b/pkg/analyzer/test/src/dart/sdk/patch_test.dart
index 840d4c5280c7eac3f27d3c210147dc4c4043d597..ba8b616e51805db8d06dbe488d1d274230f32f93 100644
--- a/pkg/analyzer/test/src/dart/sdk/patch_test.dart
+++ b/pkg/analyzer/test/src/dart/sdk/patch_test.dart
@@ -390,6 +390,65 @@ final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
}, throwsArgumentError);
}
+ test_part() {
+ String baseLibCode = r'''
+library test;
+part 'test_part.dart';
+class A {}
+''';
+ String basePartCode = r'''
+part of test;
+class B {}
+''';
+ _setSdkLibraries(r'''
+final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
+ 'test' : const LibraryInfo(
+ 'test/test.dart',
+ patches: {VM_PLATFORM: ['test/test_patch.dart']}),
+};''');
+ File fileLib = provider.newFile(_p('/sdk/lib/test/test.dart'), baseLibCode);
+ File filePart =
+ provider.newFile(_p('/sdk/lib/test/test_part.dart'), basePartCode);
+ provider.newFile(
+ _p('/sdk/lib/test/test_patch.dart'),
+ r'''
+import 'foo.dart';
+
+@patch
+class A {
+ int _a() => 1;
+}
+
+@patch
+class B {
+ int _b() => 1;
+}
+
+class _C {}
+''');
+
+ _createSdk();
+
+ {
+ Uri uri = FastUri.parse('dart:test');
+ Source source = fileLib.createSource(uri);
+ CompilationUnit unit = SdkPatcher.parse(source, true, listener);
+ patcher.patch(sdk, SdkLibraryImpl.VM_PLATFORM, listener, source, unit);
+ _assertUnitCode(
+ unit,
+ "library test; part 'test_part.dart'; import 'foo.dart'; "
+ "class A {int _a() => 1;} class _C {}");
+ }
+
+ {
+ Uri uri = FastUri.parse('dart:test/test_part.dart');
+ Source source = filePart.createSource(uri);
+ CompilationUnit unit = SdkPatcher.parse(source, true, listener);
+ patcher.patch(sdk, SdkLibraryImpl.VM_PLATFORM, listener, source, unit);
+ _assertUnitCode(unit, "part of test; class B {int _b() => 1;}");
+ }
+ }
+
test_topLevel_class_append() {
CompilationUnit unit = _doTopLevelPatching(
r'''
« pkg/analyzer/lib/src/dart/sdk/patch.dart ('K') | « pkg/analyzer/lib/src/dart/sdk/patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698