| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 // Test that we can compile from dill and run the generated code with d8. | 5 // Test that we can compile from dill and run the generated code with d8. |
| 6 library dart2js.kernel.run_from_dill_test; | 6 library dart2js.kernel.run_from_dill_test; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| 11 import 'package:async_helper/async_helper.dart'; | 11 import 'package:async_helper/async_helper.dart'; |
| 12 import 'package:expect/expect.dart'; | 12 import 'package:expect/expect.dart'; |
| 13 import 'package:compiler/src/commandline_options.dart'; | 13 import 'package:compiler/src/commandline_options.dart'; |
| 14 import 'package:compiler/src/dart2js.dart' as dart2js; | 14 import 'package:compiler/src/dart2js.dart' as dart2js; |
| 15 import 'package:compiler/src/filenames.dart'; | 15 import 'package:compiler/src/filenames.dart'; |
| 16 | 16 |
| 17 import 'compiler_helper.dart'; | 17 import 'compiler_helper.dart'; |
| 18 import '../sourcemaps/stacktrace_test.dart'; | 18 import '../sourcemaps/stacktrace_test.dart'; |
| 19 import '../serialization/helper.dart'; | 19 import '../serialization/helper.dart'; |
| 20 | 20 |
| 21 const SOURCE = const { | 21 const SOURCE = const { |
| 22 'main.dart': ''' | 22 'main.dart': ''' |
| 23 main() { | 23 main() { |
| 24 print('Hello World!'); | 24 for (int i = 0; i < 10; i++) { |
| 25 if (i == 5) continue; |
| 26 print('Hello World: \$i!'); |
| 27 if (i == 7) break; |
| 28 } |
| 25 } | 29 } |
| 26 ''' | 30 ''' |
| 27 }; | 31 }; |
| 28 | 32 |
| 33 const OUTPUT = ''' |
| 34 Hello World: 0! |
| 35 Hello World: 1! |
| 36 Hello World: 2! |
| 37 Hello World: 3! |
| 38 Hello World: 4! |
| 39 Hello World: 6! |
| 40 Hello World: 7! |
| 41 '''; |
| 42 |
| 29 main(List<String> args) { | 43 main(List<String> args) { |
| 30 asyncTest(() async { | 44 asyncTest(() async { |
| 31 await mainInternal(args); | 45 await mainInternal(args); |
| 32 }); | 46 }); |
| 33 } | 47 } |
| 34 | 48 |
| 35 enum ResultKind { crashes, errors, warnings, success, failure } | 49 enum ResultKind { crashes, errors, warnings, success, failure } |
| 36 | 50 |
| 37 Future<ResultKind> mainInternal(List<String> args, | 51 Future<ResultKind> mainInternal(List<String> args, |
| 38 {bool skipWarnings: false, bool skipErrors: false}) async { | 52 {bool skipWarnings: false, bool skipErrors: false}) async { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 62 | 76 |
| 63 await dart2js.internalMain(dart2jsArgs); | 77 await dart2js.internalMain(dart2jsArgs); |
| 64 | 78 |
| 65 print('---- run from dill --------------------------------------------'); | 79 print('---- run from dill --------------------------------------------'); |
| 66 ProcessResult runResult = Process.runSync(d8executable, | 80 ProcessResult runResult = Process.runSync(d8executable, |
| 67 ['sdk/lib/_internal/js_runtime/lib/preambles/d8.js', output]); | 81 ['sdk/lib/_internal/js_runtime/lib/preambles/d8.js', output]); |
| 68 String out = '${runResult.stderr}\n${runResult.stdout}'; | 82 String out = '${runResult.stderr}\n${runResult.stdout}'; |
| 69 print('d8 output:'); | 83 print('d8 output:'); |
| 70 print(out); | 84 print(out); |
| 71 Expect.equals(0, runResult.exitCode); | 85 Expect.equals(0, runResult.exitCode); |
| 86 Expect.equals(OUTPUT, runResult.stdout.replaceAll('\r\n', '\n')); |
| 72 | 87 |
| 73 return ResultKind.success; | 88 return ResultKind.success; |
| 74 } | 89 } |
| OLD | NEW |