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

Side by Side Diff: tests/compiler/dart2js/kernel/helper.dart

Issue 2846433003: Run closed_world2_test using the normal compiler pipeline. (Closed)
Patch Set: Updated cf. comments Created 3 years, 7 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:compiler/src/compiler.dart' show Compiler; 7 import 'package:compiler/src/compiler.dart' show Compiler;
8 import 'package:compiler/src/elements/elements.dart' show Element; 8 import 'package:compiler/src/elements/elements.dart'
9 show Element, LibraryElement;
9 import 'package:compiler/src/js_backend/backend.dart' as js 10 import 'package:compiler/src/js_backend/backend.dart' as js
10 show JavaScriptBackend; 11 show JavaScriptBackend;
11 import 'package:compiler/src/commandline_options.dart' show Flags; 12 import 'package:compiler/src/commandline_options.dart' show Flags;
12 import 'package:test/test.dart'; 13 import 'package:test/test.dart';
13 14
14 import '../memory_compiler.dart'; 15 import '../memory_compiler.dart';
15 16
16 Future<String> compile(String code, 17 Future<String> compile(String code,
17 {dynamic lookup: 'main', 18 {dynamic lookup: 'main',
18 bool useKernel: true, 19 bool useKernel: true,
19 bool disableTypeInference: true, 20 bool disableTypeInference: true,
20 List<String> extraOptions: const <String>[]}) async { 21 List<String> extraOptions: const <String>[]}) async {
21 List<String> options = <String>[ 22 List<String> options = <String>[
22 Flags.disableInlining, 23 Flags.disableInlining,
23 ]; 24 ];
24 if (disableTypeInference) options.add(Flags.disableTypeInference); 25 if (disableTypeInference) options.add(Flags.disableTypeInference);
25 if (useKernel) options.add(Flags.useKernel); 26 if (useKernel) options.add(Flags.useKernel);
26 options.addAll(extraOptions); 27 options.addAll(extraOptions);
27 28
28 if (lookup is String && lookup != 'main' && !code.contains('main')) { 29 if (lookup is String && lookup != 'main' && !code.contains('main')) {
29 code = "$code\n\nmain() => $lookup;"; 30 code = "$code\n\nmain() => $lookup;";
30 } 31 }
31 CompilationResult result = await runCompiler( 32 CompilationResult result = await runCompiler(
32 memorySourceFiles: {'main.dart': code}, options: options); 33 memorySourceFiles: {'main.dart': code}, options: options);
33 expect(result.isSuccess, isTrue); 34 expect(result.isSuccess, isTrue);
34 Compiler compiler = result.compiler; 35 Compiler compiler = result.compiler;
36 LibraryElement mainApp = compiler.mainApp;
35 Element element; 37 Element element;
36 if (lookup is String) { 38 if (lookup is String) {
37 element = compiler.mainApp.find(lookup); 39 element = mainApp.find(lookup);
38 } else { 40 } else {
39 element = lookup(compiler); 41 element = lookup(compiler);
40 } 42 }
41 js.JavaScriptBackend backend = compiler.backend; 43 js.JavaScriptBackend backend = compiler.backend;
42 return backend.getGeneratedCode(element); 44 return backend.getGeneratedCode(element);
43 } 45 }
44 46
45 /// Checks that the given Dart [code] compiles to the same JS in kernel and 47 /// Checks that the given Dart [code] compiles to the same JS in kernel and
46 /// normal mode. 48 /// normal mode.
47 /// 49 ///
(...skipping 10 matching lines...) Expand all
58 useKernel: false, 60 useKernel: false,
59 disableTypeInference: disableTypeInference, 61 disableTypeInference: disableTypeInference,
60 extraOptions: extraOptions); 62 extraOptions: extraOptions);
61 var kernel = await compile(code, 63 var kernel = await compile(code,
62 lookup: lookup, 64 lookup: lookup,
63 useKernel: true, 65 useKernel: true,
64 disableTypeInference: disableTypeInference, 66 disableTypeInference: disableTypeInference,
65 extraOptions: extraOptions); 67 extraOptions: extraOptions);
66 expect(kernel, original); 68 expect(kernel, original);
67 } 69 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/kernel/constructors_test.dart ('k') | tests/compiler/dart2js/mock_compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698