mirror of
https://github.com/dart-lang/sdk
synced 2024-10-07 08:50:47 +00:00
Issue 47842. Add a test for extension from other package.
Bug: https://github.com/dart-lang/sdk/issues/47842 Change-Id: Ib6c4d6791f823191ef39998a6e350c48915d52fa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222243 Reviewed-by: Phil Quitslund <pquitslund@google.com>
This commit is contained in:
parent
df48d2f744
commit
76bfec126d
|
@ -264,8 +264,7 @@ abstract class FixProcessorTest extends BaseFixProcessorTest {
|
|||
|
||||
Future<void> addUnimportedFile(String filePath, String content) async {
|
||||
addSource(filePath, content);
|
||||
var result = await session.getResolvedUnit(convertPath(filePath));
|
||||
extensionCache.cacheFromResult(result as ResolvedUnitResult);
|
||||
await cacheExtensionsForFile(filePath);
|
||||
}
|
||||
|
||||
Future<void> assertHasFix(String expected,
|
||||
|
@ -378,6 +377,11 @@ abstract class FixProcessorTest extends BaseFixProcessorTest {
|
|||
await _assertNoFixAllFix(error);
|
||||
}
|
||||
|
||||
Future<void> cacheExtensionsForFile(String path) async {
|
||||
var result = await session.getResolvedUnit(convertPath(path));
|
||||
extensionCache.cacheFromResult(result as ResolvedUnitResult);
|
||||
}
|
||||
|
||||
List<LinkedEditSuggestion> expectedSuggestions(
|
||||
LinkedEditSuggestionKind kind, List<String> values) {
|
||||
return values.map((value) {
|
||||
|
|
|
@ -234,6 +234,48 @@ void f(String s) {
|
|||
''');
|
||||
}
|
||||
|
||||
@FailingTest(reason: 'We suggest importing src/b.dart')
|
||||
Future<void> test_extension_otherPackage_exported_fromSrc() async {
|
||||
var pkgRootPath = '/.pub-cache/aaa';
|
||||
|
||||
var a = newFile('$pkgRootPath/lib/a.dart', content: r'''
|
||||
export 'src/b.dart';
|
||||
''');
|
||||
|
||||
var b = newFile('$pkgRootPath/lib/src/b.dart', content: r'''
|
||||
extension IntExtension on int {
|
||||
int get foo => 0;
|
||||
}
|
||||
''');
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: pkgRootPath),
|
||||
);
|
||||
|
||||
updateTestPubspecFile('''
|
||||
dependencies:
|
||||
aaa: any
|
||||
''');
|
||||
|
||||
await cacheExtensionsForFile(a.path);
|
||||
await cacheExtensionsForFile(b.path);
|
||||
|
||||
await resolveTestCode('''
|
||||
void f() {
|
||||
0.foo;
|
||||
}
|
||||
''');
|
||||
|
||||
await assertHasFix('''
|
||||
import 'package:aaa/a.dart';
|
||||
|
||||
void f() {
|
||||
0.foo;
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_invalidUri_interpolation() async {
|
||||
addSource('$testPackageLibPath/lib.dart', r'''
|
||||
class Test {
|
||||
|
|
Loading…
Reference in a new issue