| 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 a63459e72740268172ccc09445f854ed28691b1f..7e7eeeb56dac9762d3031e77c9c86663b0793432 100644
|
| --- a/pkg/analyzer/test/src/dart/sdk/patch_test.dart
|
| +++ b/pkg/analyzer/test/src/dart/sdk/patch_test.dart
|
| @@ -9,7 +9,6 @@ import 'package:analyzer/file_system/memory_file_system.dart';
|
| import 'package:analyzer/src/dart/sdk/patch.dart';
|
| import 'package:analyzer/src/dart/sdk/sdk.dart';
|
| import 'package:analyzer/src/generated/engine.dart';
|
| -import 'package:analyzer/src/generated/sdk.dart';
|
| import 'package:analyzer/src/generated/source.dart';
|
| import 'package:analyzer/src/util/fast_uri.dart';
|
| import 'package:test/test.dart';
|
| @@ -453,30 +452,21 @@ import 'c.dart';
|
| "import 'a.dart'; part 'b.dart'; import 'c.dart'; int bar() => 0;");
|
| }
|
|
|
| - test_fail_noSuchLibrary() {
|
| - expect(() {
|
| - _setSdkLibraries('const LIBRARIES = const {};');
|
| - _createSdk();
|
| - File file = provider.newFile(_p('/sdk/lib/test/test.dart'), '');
|
| - Source source = file.createSource(FastUri.parse('dart:test'));
|
| - CompilationUnit unit = SdkPatcher.parse(source, true, listener);
|
| - patcher.patch(sdk, SdkLibraryImpl.VM_PLATFORM, listener, source, unit);
|
| - }, throwsArgumentError);
|
| - }
|
| -
|
| test_fail_patchFileDoesNotExist() {
|
| expect(() {
|
| _setSdkLibraries(r'''
|
| final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
|
| 'test' : const LibraryInfo(
|
| - 'test/test.dart',
|
| - patches: {VM_PLATFORM: ['does_not_exists.dart']}),
|
| + 'test/test.dart'),
|
| };''');
|
| _createSdk();
|
| + var patchPaths = {
|
| + 'dart:test': [_p('/sdk/lib/does_not_exist.dart')]
|
| + };
|
| File file = provider.newFile(_p('/sdk/lib/test/test.dart'), '');
|
| Source source = file.createSource(FastUri.parse('dart:test'));
|
| CompilationUnit unit = SdkPatcher.parse(source, true, listener);
|
| - patcher.patch(sdk, SdkLibraryImpl.VM_PLATFORM, listener, source, unit);
|
| + patcher.patch(provider, true, patchPaths, listener, source, unit);
|
| }, throwsArgumentError);
|
| }
|
|
|
| @@ -484,9 +474,11 @@ final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
|
| _setSdkLibraries(r'''
|
| final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
|
| '_internal' : const LibraryInfo(
|
| - 'internal/internal.dart',
|
| - patches: {VM_PLATFORM: ['internal/internal_patch.dart']}),
|
| + 'internal/internal.dart'),
|
| };''');
|
| + var patchPaths = {
|
| + 'dart:_internal': [_p('/sdk/lib/internal/internal_patch.dart')]
|
| + };
|
| File file = provider.newFile(
|
| _p('/sdk/lib/internal/internal.dart'),
|
| r'''
|
| @@ -513,7 +505,7 @@ int newFunction() => 2;
|
|
|
| Source source = file.createSource(FastUri.parse('dart:_internal'));
|
| CompilationUnit unit = SdkPatcher.parse(source, true, listener);
|
| - patcher.patch(sdk, SdkLibraryImpl.VM_PLATFORM, listener, source, unit);
|
| + patcher.patch(provider, true, patchPaths, listener, source, unit);
|
| _assertUnitCode(
|
| unit,
|
| 'library dart._internal; class A {} '
|
| @@ -537,6 +529,9 @@ final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
|
| 'test/test.dart',
|
| patches: {VM_PLATFORM: ['test/test_patch.dart']}),
|
| };''');
|
| + var patchPaths = {
|
| + 'dart:test': [_p('/sdk/lib/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);
|
| @@ -564,7 +559,7 @@ class _C {}
|
| 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);
|
| + patcher.patch(provider, true, patchPaths, listener, source, unit);
|
| _assertUnitCode(
|
| unit,
|
| "library test; part 'test_part.dart'; import 'foo.dart'; "
|
| @@ -575,7 +570,7 @@ 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);
|
| + patcher.patch(provider, true, patchPaths, listener, source, unit);
|
| _assertUnitCode(unit, "part of test; class B {int _b() => 1;}");
|
| }
|
| }
|
| @@ -621,20 +616,6 @@ class B {}
|
| }, throwsArgumentError);
|
| }
|
|
|
| - test_topLevel_topLevelVariable_append() {
|
| - CompilationUnit unit = _doTopLevelPatching(
|
| - r'''
|
| -int foo() => 0;
|
| -''',
|
| - r'''
|
| -int _bar;
|
| -''');
|
| - _assertUnitCode(unit, 'int foo() => 0; int _bar;');
|
| - FunctionDeclaration a = unit.declarations[0];
|
| - TopLevelVariableDeclaration b = unit.declarations[1];
|
| - _assertPrevNextToken(a.endToken, b.beginToken);
|
| - }
|
| -
|
| test_topLevel_function_append() {
|
| CompilationUnit unit = _doTopLevelPatching(
|
| r'''
|
| @@ -798,6 +779,20 @@ void set foo(int val) {}
|
| _assertUnitCode(unit, 'void set foo(int val) {} int bar() => 2;');
|
| }
|
|
|
| + test_topLevel_topLevelVariable_append() {
|
| + CompilationUnit unit = _doTopLevelPatching(
|
| + r'''
|
| +int foo() => 0;
|
| +''',
|
| + r'''
|
| +int _bar;
|
| +''');
|
| + _assertUnitCode(unit, 'int foo() => 0; int _bar;');
|
| + FunctionDeclaration a = unit.declarations[0];
|
| + TopLevelVariableDeclaration b = unit.declarations[1];
|
| + _assertPrevNextToken(a.endToken, b.beginToken);
|
| + }
|
| +
|
| void _assertUnitCode(CompilationUnit unit, String expectedCode) {
|
| expect(unit.toSource(), expectedCode);
|
| }
|
| @@ -811,9 +806,11 @@ void set foo(int val) {}
|
| _setSdkLibraries(r'''
|
| final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
|
| 'test' : const LibraryInfo(
|
| - 'test/test.dart',
|
| - patches: {VM_PLATFORM: ['test/test_patch.dart']}),
|
| + 'test/test.dart'),
|
| };''');
|
| + var patchPaths = {
|
| + 'dart:test': [_p('/sdk/lib/test/test_patch.dart')]
|
| + };
|
| File file = provider.newFile(_p('/sdk/lib/test/test.dart'), baseCode);
|
| provider.newFile(_p('/sdk/lib/test/test_patch.dart'), patchCode);
|
|
|
| @@ -821,7 +818,7 @@ final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
|
|
|
| Source source = file.createSource(FastUri.parse('dart:test'));
|
| CompilationUnit unit = SdkPatcher.parse(source, true, listener);
|
| - patcher.patch(sdk, SdkLibraryImpl.VM_PLATFORM, listener, source, unit);
|
| + patcher.patch(provider, true, patchPaths, listener, source, unit);
|
| return unit;
|
| }
|
|
|
|
|