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

Unified Diff: tests/compiler/dart2js/kernel/helper.dart

Issue 2498493003: kernel->ssa: get simple constructors working (Closed)
Patch Set: respond to comments Created 4 years, 1 month 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: tests/compiler/dart2js/kernel/helper.dart
diff --git a/tests/compiler/dart2js/kernel/helper.dart b/tests/compiler/dart2js/kernel/helper.dart
index d7d4b11f6ee1e10d4ad25ac2cd351b43027c5e81..cbb1638bc1fb9f6591e2ac287b992ae8edb73bde 100644
--- a/tests/compiler/dart2js/kernel/helper.dart
+++ b/tests/compiler/dart2js/kernel/helper.dart
@@ -14,7 +14,7 @@ import 'package:test/test.dart';
import '../memory_compiler.dart';
Future<String> compile(String code,
- {String entry: 'main',
+ {dynamic lookup: 'main',
bool useKernel: true,
bool disableTypeInference: true,
List<String> extraOptions: const <String>[]}) async {
@@ -25,29 +25,41 @@ Future<String> compile(String code,
if (useKernel) options.add(Flags.useKernel);
options.addAll(extraOptions);
- if (entry != 'main' && !code.contains('main')) {
- code = "$code\n\nmain() => $entry;";
+ if (lookup is String && lookup != 'main' && !code.contains('main')) {
+ code = "$code\n\nmain() => $lookup;";
}
CompilationResult result = await runCompiler(
memorySourceFiles: {'main.dart': code}, options: options);
expect(result.isSuccess, isTrue);
Compiler compiler = result.compiler;
- Element element = compiler.mainApp.find(entry);
+ Element element;
+ if (lookup is String) {
+ element = compiler.mainApp.find(lookup);
+ } else {
+ element = lookup(compiler);
+ }
js.JavaScriptBackend backend = compiler.backend;
return backend.getGeneratedCode(element);
}
+/// Checks that the given Dart [code] compiles to the same JS in kernel and
+/// normal mode.
+///
+/// The function to check at the end is given by [lookup]. If [lookup] is a
+/// String, then the generated code for a top-level element named [lookup] is
+/// checked. Otherwise, [lookup] is a function that takes a [Compiler] and
+/// returns an [Element], and the returned [Element] is checked.
Future check(String code,
- {String entry: 'main',
+ {dynamic lookup: 'main',
bool disableTypeInference: true,
List<String> extraOptions: const <String>[]}) async {
var original = await compile(code,
- entry: entry,
+ lookup: lookup,
useKernel: false,
disableTypeInference: disableTypeInference,
extraOptions: extraOptions);
var kernel = await compile(code,
- entry: entry,
+ lookup: lookup,
useKernel: true,
disableTypeInference: disableTypeInference,
extraOptions: extraOptions);
« no previous file with comments | « tests/compiler/dart2js/kernel/constructors_test.dart ('k') | tests/compiler/dart2js/kernel/simple_function_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698