Files
sdk/pkg/vm/test/transformations/deferred_loading_test.dart
T
Nate Bosch 33e174084a Replace Uri.scheme == with Uri.isScheme
Use `hasScheme` in place of comparing against the empty string, and
`isScheme` to compare against all other schemes.

TEST=No behavior changes.

Change-Id: Ifc9fd13c6cf37933ebd4a754c4b500dedbcb291b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231185
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-02-08 21:38:57 +00:00

55 lines
1.7 KiB
Dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'package:kernel/target/targets.dart';
import 'package:kernel/ast.dart';
import 'package:kernel/kernel.dart';
import 'package:test/test.dart';
import 'package:vm/transformations/deferred_loading.dart'
show transformComponent;
import '../common_test_utils.dart';
final String pkgVmDir = Platform.script.resolve('../..').toFilePath();
runTestCase(Uri source) async {
final target = new TestingVmTarget(new TargetFlags());
Component component =
await compileTestCaseToKernelProgram(source, target: target);
// Disrupt the import order as a way of simulating issue 42985.
final reversed = component.libraries.reversed.toList();
component.libraries.setAll(0, reversed);
component = transformComponent(component);
// Remove core libraries so the expected output isn't enormous and broken by
// core libraries changes.
component.libraries.removeWhere((lib) => lib.importUri.isScheme("dart"));
String actual = kernelComponentToString(component);
// Remove absolute library URIs.
actual = actual.replaceAll(new Uri.file(pkgVmDir).toString(), '#pkg/vm');
compareResultWithExpectationsFile(source, actual);
}
main() {
group('deferred-loading', () {
final testCasesDir =
new Directory(pkgVmDir + '/testcases/transformations/deferred_loading');
for (var entry in testCasesDir
.listSync(recursive: true, followLinks: false)
.reversed) {
if (entry.path.endsWith("main.dart")) {
test(entry.path, () => runTestCase(entry.uri));
}
}
});
}