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 // Helper to test compilation equivalence between source and .dill based | 5 // Helper to test compilation equivalence between source and .dill based |
6 // compilation. | 6 // compilation. |
7 library dart2js.kernel.compile_from_dill_test_helper; | 7 library dart2js.kernel.compile_from_dill_test_helper; |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 11 matching lines...) Expand all Loading... |
22 import 'package:compiler/src/universe/world_builder.dart'; | 22 import 'package:compiler/src/universe/world_builder.dart'; |
23 import 'package:compiler/src/world.dart'; | 23 import 'package:compiler/src/world.dart'; |
24 import 'package:expect/expect.dart'; | 24 import 'package:expect/expect.dart'; |
25 import '../memory_compiler.dart'; | 25 import '../memory_compiler.dart'; |
26 import '../equivalence/check_functions.dart'; | 26 import '../equivalence/check_functions.dart'; |
27 import '../equivalence/check_helpers.dart'; | 27 import '../equivalence/check_helpers.dart'; |
28 import 'test_helpers.dart'; | 28 import 'test_helpers.dart'; |
29 | 29 |
30 import 'compiler_helper.dart'; | 30 import 'compiler_helper.dart'; |
31 | 31 |
| 32 const SOURCE = const { |
| 33 'main.dart': ''' |
| 34 foo({named}) => 1; |
| 35 bar(a) => !a; |
| 36 class Class { |
| 37 var field; |
| 38 static var staticField; |
| 39 |
| 40 Class(); |
| 41 Class.named(this.field); |
| 42 |
| 43 method() {} |
| 44 } |
| 45 |
| 46 class SubClass extends Class { |
| 47 method() { |
| 48 super.method(); |
| 49 } |
| 50 } |
| 51 main() { |
| 52 foo(); |
| 53 bar(true); |
| 54 []; |
| 55 {}; |
| 56 new Object(); |
| 57 new Class.named(''); |
| 58 new SubClass().method(); |
| 59 Class.staticField; |
| 60 var x = null; |
| 61 var y1 = x == null; |
| 62 var y2 = null == x; |
| 63 var z1 = x?.toString(); |
| 64 var z2 = x ?? y1; |
| 65 var z3 = x ??= y2; |
| 66 var w = x == null ? null : x.toString(); |
| 67 for (int i = 0; i < 10; i++) { |
| 68 if (i == 5) continue; |
| 69 x = i; |
| 70 if (i == 5) break; |
| 71 } |
| 72 int i = 0; |
| 73 while (i < 10) { |
| 74 if (i == 5) continue; |
| 75 x = i; |
| 76 if (i == 5) break; |
| 77 } |
| 78 for (var v in [3, 5]) { |
| 79 if (v == 5) continue; |
| 80 x = v; |
| 81 if (v == 5) break; |
| 82 } |
| 83 print(x); |
| 84 return x; |
| 85 } |
| 86 ''' |
| 87 }; |
| 88 |
32 enum ResultKind { crashes, errors, warnings, success, failure } | 89 enum ResultKind { crashes, errors, warnings, success, failure } |
33 | 90 |
34 Future<ResultKind> runTest( | 91 Future<ResultKind> runTest( |
35 Uri entryPoint, Map<String, String> memorySourceFiles, | 92 Uri entryPoint, Map<String, String> memorySourceFiles, |
36 {bool skipWarnings: false, | 93 {bool skipWarnings: false, |
37 bool skipErrors: false, | 94 bool skipErrors: false, |
38 bool verbose: false, | 95 bool verbose: false, |
39 List<String> options: const <String>[]}) async { | 96 List<String> options: const <String>[]}) async { |
40 enableDebugMode(); | 97 enableDebugMode(); |
41 EnumCreator.matchKernelRepresentationForTesting = true; | 98 EnumCreator.matchKernelRepresentationForTesting = true; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 208 } |
152 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; | 209 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; |
153 checkSets(map1.keys, map2.keys, 'output', equality); | 210 checkSets(map1.keys, map2.keys, 'output', equality); |
154 map1.forEach((String name, BufferedOutputSink output1) { | 211 map1.forEach((String name, BufferedOutputSink output1) { |
155 BufferedOutputSink output2 = map2[name]; | 212 BufferedOutputSink output2 = map2[name]; |
156 Expect.stringEquals(output1.text, output2.text); | 213 Expect.stringEquals(output1.text, output2.text); |
157 }); | 214 }); |
158 }); | 215 }); |
159 return ResultKind.success; | 216 return ResultKind.success; |
160 } | 217 } |
OLD | NEW |