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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 Expect.isFalse(compiler2.compilationFailed); | 134 Expect.isFalse(compiler2.compilationFailed); |
135 | 135 |
136 KernelEquivalence equivalence = new KernelEquivalence(elementMap); | 136 KernelEquivalence equivalence = new KernelEquivalence(elementMap); |
137 | 137 |
138 ClosedWorld closedWorld2 = | 138 ClosedWorld closedWorld2 = |
139 compiler2.resolutionWorldBuilder.closedWorldForTesting; | 139 compiler2.resolutionWorldBuilder.closedWorldForTesting; |
140 | 140 |
141 checkBackendUsage(closedWorld1.backendUsage, closedWorld2.backendUsage, | 141 checkBackendUsage(closedWorld1.backendUsage, closedWorld2.backendUsage, |
142 equivalence.defaultStrategy); | 142 equivalence.defaultStrategy); |
143 | 143 |
144 print('--- checking resolution enqueuers ----------------------------------'); | |
145 checkResolutionEnqueuers(closedWorld1.backendUsage, closedWorld2.backendUsage, | 144 checkResolutionEnqueuers(closedWorld1.backendUsage, closedWorld2.backendUsage, |
146 compiler1.enqueuer.resolution, compiler2.enqueuer.resolution, | 145 compiler1.enqueuer.resolution, compiler2.enqueuer.resolution, |
147 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b), | 146 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b), |
148 typeEquivalence: (ResolutionDartType a, DartType b) { | 147 typeEquivalence: (ResolutionDartType a, DartType b) { |
149 return equivalence.typeEquivalence(unalias(a), b); | 148 return equivalence.typeEquivalence(unalias(a), b); |
150 }, | 149 }, |
151 elementFilter: elementFilter, | 150 elementFilter: elementFilter, |
152 verbose: arguments.verbose); | 151 verbose: arguments.verbose); |
153 | 152 |
154 print('--- checking closed worlds -----------------------------------------'); | |
155 checkClosedWorlds(closedWorld1, closedWorld2, | 153 checkClosedWorlds(closedWorld1, closedWorld2, |
156 strategy: equivalence.defaultStrategy, | 154 strategy: equivalence.defaultStrategy, |
157 verbose: arguments.verbose, | 155 verbose: arguments.verbose, |
158 // TODO(johnniwinther,efortuna): Require closure class equivalence when | 156 // TODO(johnniwinther,efortuna): Require closure class equivalence when |
159 // these are supported. | 157 // these are supported. |
160 allowMissingClosureClasses: true); | 158 allowMissingClosureClasses: true); |
161 | 159 |
162 // TODO(johnniwinther): Perform equivalence tests on the model: codegen world | 160 // TODO(johnniwinther): Perform equivalence tests on the model: codegen world |
163 // impacts, program model, etc. | 161 // impacts, program model, etc. |
164 | 162 |
165 print('--- checking codegen enqueuers--------------------------------------'); | |
166 checkCodegenEnqueuers(compiler1.enqueuer.codegenEnqueuerForTesting, | 163 checkCodegenEnqueuers(compiler1.enqueuer.codegenEnqueuerForTesting, |
167 compiler2.enqueuer.codegenEnqueuerForTesting, | 164 compiler2.enqueuer.codegenEnqueuerForTesting, |
168 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b), | 165 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b), |
169 typeEquivalence: (ResolutionDartType a, DartType b) { | 166 typeEquivalence: (ResolutionDartType a, DartType b) { |
170 return equivalence.typeEquivalence(unalias(a), b); | 167 return equivalence.typeEquivalence(unalias(a), b); |
171 }, | 168 }, |
172 elementFilter: elementFilter, | 169 elementFilter: elementFilter, |
173 verbose: arguments.verbose); | 170 verbose: arguments.verbose); |
174 | 171 |
175 print('--- checking output------- -----------------------------------------'); | |
176 collector1.outputMap | 172 collector1.outputMap |
177 .forEach((OutputType outputType, Map<String, BufferedOutputSink> map1) { | 173 .forEach((OutputType outputType, Map<String, BufferedOutputSink> map1) { |
178 if (outputType == OutputType.sourceMap) { | 174 if (outputType == OutputType.sourceMap) { |
179 // TODO(johnniwinther): Support source map from .dill. | 175 // TODO(johnniwinther): Support source map from .dill. |
180 return; | 176 return; |
181 } | 177 } |
182 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; | 178 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; |
183 checkSets(map1.keys, map2.keys, 'output', equality); | 179 checkSets(map1.keys, map2.keys, 'output', equality); |
184 map1.forEach((String name, BufferedOutputSink output1) { | 180 map1.forEach((String name, BufferedOutputSink output1) { |
185 BufferedOutputSink output2 = map2[name]; | 181 BufferedOutputSink output2 = map2[name]; |
186 Expect.stringEquals(output1.text, output2.text); | 182 Expect.stringEquals(output1.text, output2.text); |
187 }); | 183 }); |
188 }); | 184 }); |
189 return ResultKind.success; | 185 return ResultKind.success; |
190 } | 186 } |
OLD | NEW |