OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // Test compilation equivalence between source and .dill based |
| 6 // compilation using the fast_startup emitter. |
| 7 library dart2js.kernel.compile_from_dill_fast_startup_test; |
| 8 |
| 9 import 'dart:async'; |
| 10 import 'package:async_helper/async_helper.dart'; |
| 11 import 'package:compiler/src/commandline_options.dart'; |
| 12 import '../serialization/helper.dart'; |
| 13 |
| 14 import 'compile_from_dill_test_helper.dart'; |
| 15 |
| 16 // TODO(johnniwinther): Maybe share this with 'compile_from_dill_test.dart'. |
| 17 const SOURCE = const { |
| 18 'main.dart': ''' |
| 19 foo({named}) => 1; |
| 20 bar(a) => !a; |
| 21 class Class { |
| 22 var field; |
| 23 static var staticField; |
| 24 Class(this.field); |
| 25 } |
| 26 main() { |
| 27 foo(); |
| 28 bar(true); |
| 29 []; |
| 30 {}; |
| 31 new Object(); |
| 32 new Class(''); |
| 33 Class.staticField; |
| 34 var x = null; |
| 35 for (int i = 0; i < 10; i++) { |
| 36 x = i; |
| 37 if (i == 5) break; |
| 38 } |
| 39 return x; |
| 40 } |
| 41 ''' |
| 42 }; |
| 43 |
| 44 main(List<String> args) { |
| 45 asyncTest(() async { |
| 46 await mainInternal(args); |
| 47 }); |
| 48 } |
| 49 |
| 50 Future<ResultKind> mainInternal(List<String> args, |
| 51 {bool skipWarnings: false, bool skipErrors: false}) async { |
| 52 Arguments arguments = new Arguments.from(args); |
| 53 Uri entryPoint; |
| 54 Map<String, String> memorySourceFiles; |
| 55 if (arguments.uri != null) { |
| 56 entryPoint = arguments.uri; |
| 57 memorySourceFiles = const <String, String>{}; |
| 58 } else { |
| 59 entryPoint = Uri.parse('memory:main.dart'); |
| 60 memorySourceFiles = SOURCE; |
| 61 } |
| 62 |
| 63 return runTest(entryPoint, memorySourceFiles, |
| 64 verbose: arguments.verbose, |
| 65 skipWarnings: skipWarnings, |
| 66 skipErrors: skipErrors, |
| 67 options: [Flags.fastStartup]); |
| 68 } |
OLD | NEW |