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'; |
11 | 11 |
12 import 'package:async_helper/async_helper.dart'; | 12 import 'package:async_helper/async_helper.dart'; |
13 import 'package:compiler/compiler_new.dart'; | 13 import 'package:compiler/compiler_new.dart'; |
14 import 'package:compiler/src/commandline_options.dart'; | 14 import 'package:compiler/src/commandline_options.dart'; |
15 import 'package:compiler/src/common.dart'; | 15 import 'package:compiler/src/common.dart'; |
16 import 'package:compiler/src/compiler.dart'; | 16 import 'package:compiler/src/compiler.dart'; |
17 import 'package:compiler/src/elements/resolution_types.dart'; | |
18 import 'package:compiler/src/elements/types.dart'; | 17 import 'package:compiler/src/elements/types.dart'; |
19 import 'package:compiler/src/kernel/element_map.dart'; | 18 import 'package:compiler/src/kernel/element_map.dart'; |
20 import 'package:compiler/src/kernel/kernel_strategy.dart'; | 19 import 'package:compiler/src/kernel/kernel_strategy.dart'; |
21 import 'package:compiler/src/serialization/equivalence.dart'; | 20 import 'package:compiler/src/serialization/equivalence.dart'; |
22 import 'package:compiler/src/resolution/enum_creator.dart'; | 21 import 'package:compiler/src/resolution/enum_creator.dart'; |
23 import 'package:compiler/src/universe/world_builder.dart'; | 22 import 'package:compiler/src/universe/world_builder.dart'; |
24 import 'package:compiler/src/world.dart'; | 23 import 'package:compiler/src/world.dart'; |
25 import 'package:expect/expect.dart'; | 24 import 'package:expect/expect.dart'; |
26 import '../memory_compiler.dart'; | 25 import '../memory_compiler.dart'; |
27 import '../equivalence/check_functions.dart'; | 26 import '../equivalence/check_functions.dart'; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 136 |
138 ClosedWorld closedWorld2 = | 137 ClosedWorld closedWorld2 = |
139 compiler2.resolutionWorldBuilder.closedWorldForTesting; | 138 compiler2.resolutionWorldBuilder.closedWorldForTesting; |
140 | 139 |
141 checkBackendUsage(closedWorld1.backendUsage, closedWorld2.backendUsage, | 140 checkBackendUsage(closedWorld1.backendUsage, closedWorld2.backendUsage, |
142 equivalence.defaultStrategy); | 141 equivalence.defaultStrategy); |
143 | 142 |
144 checkResolutionEnqueuers(closedWorld1.backendUsage, closedWorld2.backendUsage, | 143 checkResolutionEnqueuers(closedWorld1.backendUsage, closedWorld2.backendUsage, |
145 compiler1.enqueuer.resolution, compiler2.enqueuer.resolution, | 144 compiler1.enqueuer.resolution, compiler2.enqueuer.resolution, |
146 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b), | 145 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b), |
147 typeEquivalence: (ResolutionDartType a, DartType b) { | 146 typeEquivalence: (DartType a, DartType b) { |
148 return equivalence.typeEquivalence(unalias(a), b); | 147 return equivalence.typeEquivalence(unalias(a), b); |
149 }, | 148 }, |
150 elementFilter: elementFilter, | 149 elementFilter: elementFilter, |
151 verbose: arguments.verbose); | 150 verbose: arguments.verbose); |
152 | 151 |
153 checkClosedWorlds(closedWorld1, closedWorld2, | 152 checkClosedWorlds(closedWorld1, closedWorld2, |
154 strategy: equivalence.defaultStrategy, | 153 strategy: equivalence.defaultStrategy, |
155 verbose: arguments.verbose, | 154 verbose: arguments.verbose, |
156 // TODO(johnniwinther,efortuna): Require closure class equivalence when | 155 // TODO(johnniwinther,efortuna): Require closure class equivalence when |
157 // these are supported. | 156 // these are supported. |
158 allowMissingClosureClasses: true); | 157 allowMissingClosureClasses: true); |
159 | 158 |
160 // TODO(johnniwinther): Perform equivalence tests on the model: codegen world | 159 // TODO(johnniwinther): Perform equivalence tests on the model: codegen world |
161 // impacts, program model, etc. | 160 // impacts, program model, etc. |
162 | 161 |
163 checkCodegenEnqueuers(compiler1.enqueuer.codegenEnqueuerForTesting, | 162 checkCodegenEnqueuers(compiler1.enqueuer.codegenEnqueuerForTesting, |
164 compiler2.enqueuer.codegenEnqueuerForTesting, | 163 compiler2.enqueuer.codegenEnqueuerForTesting, |
165 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b), | 164 elementEquivalence: (a, b) => equivalence.entityEquivalence(a, b), |
166 typeEquivalence: (ResolutionDartType a, DartType b) { | 165 typeEquivalence: (DartType a, DartType b) { |
167 return equivalence.typeEquivalence(unalias(a), b); | 166 return equivalence.typeEquivalence(unalias(a), b); |
168 }, | 167 }, |
169 elementFilter: elementFilter, | 168 elementFilter: elementFilter, |
170 verbose: arguments.verbose); | 169 verbose: arguments.verbose); |
171 | 170 |
172 collector1.outputMap | 171 collector1.outputMap |
173 .forEach((OutputType outputType, Map<String, BufferedOutputSink> map1) { | 172 .forEach((OutputType outputType, Map<String, BufferedOutputSink> map1) { |
174 if (outputType == OutputType.sourceMap) { | 173 if (outputType == OutputType.sourceMap) { |
175 // TODO(johnniwinther): Support source map from .dill. | 174 // TODO(johnniwinther): Support source map from .dill. |
176 return; | 175 return; |
177 } | 176 } |
178 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; | 177 Map<String, BufferedOutputSink> map2 = collector2.outputMap[outputType]; |
179 checkSets(map1.keys, map2.keys, 'output', equality); | 178 checkSets(map1.keys, map2.keys, 'output', equality); |
180 map1.forEach((String name, BufferedOutputSink output1) { | 179 map1.forEach((String name, BufferedOutputSink output1) { |
181 BufferedOutputSink output2 = map2[name]; | 180 BufferedOutputSink output2 = map2[name]; |
182 Expect.stringEquals(output1.text, output2.text); | 181 Expect.stringEquals(output1.text, output2.text); |
183 }); | 182 }); |
184 }); | 183 }); |
185 return ResultKind.success; | 184 return ResultKind.success; |
186 } | 185 } |
OLD | NEW |