mirror of
https://github.com/dart-lang/sdk
synced 2024-07-08 12:06:26 +00:00
Add negative dart:_wasm test, fix SdkLibrary.isInternal
While doing a previous CL, noticed that we don't actually report the corresponding error. Change-Id: I77ae11de6f6e84b3625b13db803e846966c806d6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333641 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
f3cd5c1473
commit
c753f25160
|
@ -349,7 +349,7 @@ class SdkLibraryImpl implements SdkLibrary {
|
|||
bool get isImplementation => _implementation;
|
||||
|
||||
@override
|
||||
bool get isInternal => category == "Internal";
|
||||
bool get isInternal => shortName.startsWith('dart:_');
|
||||
|
||||
@override
|
||||
bool get isShared => category == "Shared";
|
||||
|
|
|
@ -714,7 +714,7 @@ class A {}
|
|||
|
||||
// Configure `package:my`.
|
||||
writePackageConfig(
|
||||
getFile('${myRoot.path}/.dart_tool/package_config.json').path,
|
||||
myRoot.path,
|
||||
PackageConfigFileBuilder()..add(name: 'my', rootPath: myRoot.path),
|
||||
);
|
||||
|
||||
|
|
|
@ -353,12 +353,8 @@ class PubPackageResolutionTest extends ContextResolutionTest {
|
|||
}) async {
|
||||
final rootFolder = getFolder('$workspaceRootPath/foo');
|
||||
|
||||
final packageConfigFile = getFile(
|
||||
'${rootFolder.path}/.dart_tool/package_config.json',
|
||||
);
|
||||
|
||||
writePackageConfig(
|
||||
packageConfigFile.path,
|
||||
rootFolder.path,
|
||||
PackageConfigFileBuilder()..add(name: 'foo', rootPath: rootFolder.path),
|
||||
);
|
||||
|
||||
|
@ -399,13 +395,14 @@ class PubPackageResolutionTest extends ContextResolutionTest {
|
|||
);
|
||||
}
|
||||
|
||||
void writePackageConfig(String path, PackageConfigFileBuilder config) {
|
||||
newFile(
|
||||
path,
|
||||
config.toContent(
|
||||
toUriStr: toUriStr,
|
||||
),
|
||||
void writePackageConfig(
|
||||
String directoryPath,
|
||||
PackageConfigFileBuilder config,
|
||||
) {
|
||||
final content = config.toContent(
|
||||
toUriStr: toUriStr,
|
||||
);
|
||||
newPackageConfigJsonFile(directoryPath, content);
|
||||
}
|
||||
|
||||
Future<File> writeSdkSummary() async {
|
||||
|
@ -488,8 +485,7 @@ class PubPackageResolutionTest extends ContextResolutionTest {
|
|||
);
|
||||
}
|
||||
|
||||
var path = '$testPackageRootPath/.dart_tool/package_config.json';
|
||||
writePackageConfig(path, config);
|
||||
writePackageConfig(testPackageRootPath, config);
|
||||
}
|
||||
|
||||
void writeTestPackageConfigWithMeta() {
|
||||
|
|
|
@ -30,8 +30,8 @@ import 'dart:_internal';
|
|||
}
|
||||
|
||||
test_wasm_fromJs() async {
|
||||
var filePath = _pathInPackage('js');
|
||||
final file = newFile(filePath, '''
|
||||
final packageRootPath = _newPackage('js');
|
||||
final file = newFile('$packageRootPath/lib/js.dart', '''
|
||||
import 'dart:_wasm';
|
||||
''');
|
||||
await resolveFile2(file);
|
||||
|
@ -40,9 +40,18 @@ import 'dart:_wasm';
|
|||
]);
|
||||
}
|
||||
|
||||
test_wasm_fromTest() async {
|
||||
await assertErrorsInCode('''
|
||||
import 'dart:_wasm';
|
||||
''', [
|
||||
error(CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, 7, 12),
|
||||
error(WarningCode.UNUSED_IMPORT, 7, 12),
|
||||
]);
|
||||
}
|
||||
|
||||
test_wasm_fromUi() async {
|
||||
var filePath = _pathInPackage('ui');
|
||||
final file = newFile(filePath, '''
|
||||
final packageRootPath = _newPackage('ui');
|
||||
final file = newFile('$packageRootPath/lib/ui.dart', '''
|
||||
import 'dart:_wasm';
|
||||
''');
|
||||
await resolveFile2(file);
|
||||
|
@ -51,16 +60,15 @@ import 'dart:_wasm';
|
|||
]);
|
||||
}
|
||||
|
||||
String _pathInPackage(String packageName) {
|
||||
var packageRoot = '$workspaceRootPath/$packageName';
|
||||
String _newPackage(String packageName) {
|
||||
var packageRootPath = '$workspaceRootPath/$packageName';
|
||||
var builder = PackageConfigFileBuilder();
|
||||
builder.add(
|
||||
name: packageName,
|
||||
rootPath: packageRoot,
|
||||
rootPath: packageRootPath,
|
||||
languageVersion: testPackageLanguageVersion,
|
||||
);
|
||||
var path = '$packageRoot/.dart_tool/package_config.json';
|
||||
writePackageConfig(path, builder);
|
||||
return '$packageRoot/lib/$packageName.dart';
|
||||
writePackageConfig(packageRootPath, builder);
|
||||
return packageRootPath;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user