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

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

Issue 2498493003: kernel->ssa: get simple constructors working (Closed)
Patch Set: 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 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' show Element;
9 import 'package:compiler/src/js_backend/backend.dart' as js 9 import 'package:compiler/src/js_backend/backend.dart' as js
10 show JavaScriptBackend; 10 show JavaScriptBackend;
11 import 'package:compiler/src/commandline_options.dart' show Flags; 11 import 'package:compiler/src/commandline_options.dart' show Flags;
12 import 'package:test/test.dart'; 12 import 'package:test/test.dart';
13 13
14 import '../memory_compiler.dart'; 14 import '../memory_compiler.dart';
15 15
16 Future<String> compile(String code, 16 Future<String> compile(String code,
17 {String entry: 'main', 17 {String entry: 'main',
18 bool useKernel: true, 18 bool useKernel: true,
19 bool disableTypeInference: true, 19 bool disableTypeInference: true,
20 List<String> extraOptions: const <String>[]}) async { 20 List<String> extraOptions: const <String>[],
21 Element checkElement(Compiler compiler)}) async {
Siggi Cherem (dart-lang) 2016/11/14 18:22:25 maybe we can merge checkElement & entry, they seem
Harry Terkelsen 2016/11/14 23:23:40 Done.
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 (entry != 'main' && !code.contains('main')) { 29 if (entry != 'main' && !code.contains('main')) {
29 code = "$code\n\nmain() => $entry;"; 30 code = "$code\n\nmain() => $entry;";
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;
35 Element element = compiler.mainApp.find(entry); 36 Element element;
37 if (checkElement == null) {
38 element = compiler.mainApp.find(entry);
39 } else {
40 element = checkElement(compiler);
41 }
36 js.JavaScriptBackend backend = compiler.backend; 42 js.JavaScriptBackend backend = compiler.backend;
37 return backend.getGeneratedCode(element); 43 return backend.getGeneratedCode(element);
38 } 44 }
39 45
40 Future check(String code, 46 Future check(String code,
41 {String entry: 'main', 47 {String entry: 'main',
42 bool disableTypeInference: true, 48 bool disableTypeInference: true,
43 List<String> extraOptions: const <String>[]}) async { 49 List<String> extraOptions: const <String>[],
50 Element checkElement(Compiler compiler)}) async {
44 var original = await compile(code, 51 var original = await compile(code,
45 entry: entry, 52 entry: entry,
46 useKernel: false, 53 useKernel: false,
47 disableTypeInference: disableTypeInference, 54 disableTypeInference: disableTypeInference,
48 extraOptions: extraOptions); 55 extraOptions: extraOptions,
56 checkElement: checkElement);
49 var kernel = await compile(code, 57 var kernel = await compile(code,
50 entry: entry, 58 entry: entry,
51 useKernel: true, 59 useKernel: true,
52 disableTypeInference: disableTypeInference, 60 disableTypeInference: disableTypeInference,
53 extraOptions: extraOptions); 61 extraOptions: extraOptions,
62 checkElement: checkElement);
54 expect(kernel, original); 63 expect(kernel, original);
55 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698