| Index: tests/compiler/dart2js/kernel/helper.dart
|
| diff --git a/tests/compiler/dart2js/kernel/helper.dart b/tests/compiler/dart2js/kernel/helper.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5f79346330bba4f364b2d8d434b685c5103c811f
|
| --- /dev/null
|
| +++ b/tests/compiler/dart2js/kernel/helper.dart
|
| @@ -0,0 +1,37 @@
|
| +// Copyright (c) 2016, 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 'package:compiler/src/elements/elements.dart' show Element;
|
| +import 'package:compiler/src/js_backend/backend.dart' show JavaScriptBackend;
|
| +import 'package:compiler/src/commandline_options.dart' show Flags;
|
| +import 'package:test/test.dart';
|
| +
|
| +import '../memory_compiler.dart';
|
| +
|
| +Future<String> compile(String code, {String entry: 'main',
|
| + bool useKernel: true}) async {
|
| + List<String> options = <String>[
|
| + Flags.disableTypeInference,
|
| + Flags.disableInlining,
|
| + ];
|
| + if (useKernel) options.add(Flags.useKernel);
|
| +
|
| + if (entry != 'main' && !code.contains('main')) {
|
| + code = "$code\n\nmain() => $entry;";
|
| + }
|
| + CompilationResult result = await runCompiler(
|
| + memorySourceFiles: {'main.dart': code},
|
| + options: options);
|
| + expect(result.isSuccess, isTrue);
|
| + Compiler compiler = result.compiler;
|
| + Element element = compiler.mainApp.find(entry);
|
| + js.JavaScriptBackend backend = compiler.backend;
|
| + return backend.getGeneratedCode(element);
|
| +}
|
| +
|
| +void check(String code, {String entry: 'main'}) async {
|
| + var original = await compile(code, entry: entry, useKernel: false);
|
| + var kernel = await compile(code, entry: entry, useKernel: true);
|
| + expect(original, kernel);
|
| +}
|
|
|