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