| 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 // Partial test that the closed world computed from [WorldImpact]s derived from | 5 // Partial test that the closed world computed from [WorldImpact]s derived from |
| 6 // kernel is equivalent to the original computed from resolution. | 6 // kernel is equivalent to the original computed from resolution. |
| 7 library dart2js.kernel.compile_from_dill_test; | 7 library dart2js.kernel.compile_from_dill_test; |
| 8 | 8 |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 import '../memory_compiler.dart'; | 26 import '../memory_compiler.dart'; |
| 27 import '../equivalence/check_functions.dart'; | 27 import '../equivalence/check_functions.dart'; |
| 28 import '../equivalence/check_helpers.dart'; | 28 import '../equivalence/check_helpers.dart'; |
| 29 import '../serialization/helper.dart'; | 29 import '../serialization/helper.dart'; |
| 30 import 'test_helpers.dart'; | 30 import 'test_helpers.dart'; |
| 31 | 31 |
| 32 import 'compiler_helper.dart'; | 32 import 'compiler_helper.dart'; |
| 33 | 33 |
| 34 const SOURCE = const { | 34 const SOURCE = const { |
| 35 'main.dart': ''' | 35 'main.dart': ''' |
| 36 foo() {} |
| 36 main() { | 37 main() { |
| 38 foo(); |
| 37 return null; | 39 return null; |
| 38 } | 40 } |
| 39 ''' | 41 ''' |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 main(List<String> args) { | 44 main(List<String> args) { |
| 43 asyncTest(() async { | 45 asyncTest(() async { |
| 44 await mainInternal(args); | 46 await mainInternal(args); |
| 45 }); | 47 }); |
| 46 } | 48 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 70 }); | 72 }); |
| 71 entryPoint = dir.uri.resolve(entryPoint.path); | 73 entryPoint = dir.uri.resolve(entryPoint.path); |
| 72 | 74 |
| 73 print('---- compile from ast ----------------------------------------------'); | 75 print('---- compile from ast ----------------------------------------------'); |
| 74 DiagnosticCollector collector = new DiagnosticCollector(); | 76 DiagnosticCollector collector = new DiagnosticCollector(); |
| 75 OutputCollector collector1 = new OutputCollector(); | 77 OutputCollector collector1 = new OutputCollector(); |
| 76 Compiler compiler1 = compilerFor( | 78 Compiler compiler1 = compilerFor( |
| 77 entryPoint: entryPoint, | 79 entryPoint: entryPoint, |
| 78 diagnosticHandler: collector, | 80 diagnosticHandler: collector, |
| 79 outputProvider: collector1, | 81 outputProvider: collector1, |
| 80 options: [Flags.disableTypeInference, Flags.enableAssertMessage]); | 82 options: [ |
| 83 Flags.disableTypeInference, |
| 84 Flags.disableInlining, |
| 85 Flags.enableAssertMessage |
| 86 ]); |
| 81 ElementResolutionWorldBuilder.useInstantiationMap = true; | 87 ElementResolutionWorldBuilder.useInstantiationMap = true; |
| 82 compiler1.resolution.retainCachesForTesting = true; | 88 compiler1.resolution.retainCachesForTesting = true; |
| 83 await compiler1.run(entryPoint); | 89 await compiler1.run(entryPoint); |
| 84 if (collector.crashes.isNotEmpty) { | 90 if (collector.crashes.isNotEmpty) { |
| 85 print('Skipping due to crashes.'); | 91 print('Skipping due to crashes.'); |
| 86 return ResultKind.crashes; | 92 return ResultKind.crashes; |
| 87 } | 93 } |
| 88 if (collector.errors.isNotEmpty && skipErrors) { | 94 if (collector.errors.isNotEmpty && skipErrors) { |
| 89 print('Skipping due to errors.'); | 95 print('Skipping due to errors.'); |
| 90 return ResultKind.errors; | 96 return ResultKind.errors; |
| 91 } | 97 } |
| 92 if (collector.warnings.isNotEmpty && skipWarnings) { | 98 if (collector.warnings.isNotEmpty && skipWarnings) { |
| 93 print('Skipping due to warnings.'); | 99 print('Skipping due to warnings.'); |
| 94 return ResultKind.warnings; | 100 return ResultKind.warnings; |
| 95 } | 101 } |
| 96 Expect.isFalse(compiler1.compilationFailed); | 102 Expect.isFalse(compiler1.compilationFailed); |
| 97 ClosedWorld closedWorld1 = | 103 ClosedWorld closedWorld1 = |
| 98 compiler1.resolutionWorldBuilder.closedWorldForTesting; | 104 compiler1.resolutionWorldBuilder.closedWorldForTesting; |
| 99 | 105 |
| 100 OutputCollector collector2 = new OutputCollector(); | 106 OutputCollector collector2 = new OutputCollector(); |
| 101 Compiler compiler2 = await compileWithDill(entryPoint, const {}, | 107 Compiler compiler2 = await compileWithDill( |
| 102 [Flags.disableTypeInference, Flags.enableAssertMessage], | 108 entryPoint, |
| 103 printSteps: true, compilerOutput: collector2); | 109 const {}, |
| 110 [ |
| 111 Flags.disableTypeInference, |
| 112 Flags.disableInlining, |
| 113 Flags.enableAssertMessage |
| 114 ], |
| 115 printSteps: true, |
| 116 compilerOutput: collector2); |
| 104 | 117 |
| 105 KernelFrontEndStrategy frontEndStrategy = compiler2.frontEndStrategy; | 118 KernelFrontEndStrategy frontEndStrategy = compiler2.frontEndStrategy; |
| 106 KernelToElementMap elementMap = frontEndStrategy.elementMap; | 119 KernelToElementMap elementMap = frontEndStrategy.elementMap; |
| 107 | 120 |
| 108 Expect.isFalse(compiler2.compilationFailed); | 121 Expect.isFalse(compiler2.compilationFailed); |
| 109 | 122 |
| 110 KernelEquivalence equivalence = new KernelEquivalence(elementMap); | 123 KernelEquivalence equivalence = new KernelEquivalence(elementMap); |
| 111 | 124 |
| 112 ClosedWorld closedWorld2 = | 125 ClosedWorld closedWorld2 = |
| 113 compiler2.resolutionWorldBuilder.closedWorldForTesting; | 126 compiler2.resolutionWorldBuilder.closedWorldForTesting; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 160 } |
| 148 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; | 161 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; |
| 149 checkSets(map1.keys, map2.keys, 'output', equality); | 162 checkSets(map1.keys, map2.keys, 'output', equality); |
| 150 map1.forEach((String name, BufferedOutputSink output1) { | 163 map1.forEach((String name, BufferedOutputSink output1) { |
| 151 BufferedOutputSink output2 = map2[name]; | 164 BufferedOutputSink output2 = map2[name]; |
| 152 Expect.stringEquals(output1.text, output2.text); | 165 Expect.stringEquals(output1.text, output2.text); |
| 153 }); | 166 }); |
| 154 }); | 167 }); |
| 155 return ResultKind.success; | 168 return ResultKind.success; |
| 156 } | 169 } |
| OLD | NEW |