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