| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.serialization_model_test; | 5 library dart2js.serialization_model_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
| 10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 String id = index != null ? '$index: ' : ''; | 70 String id = index != null ? '$index: ' : ''; |
| 71 String title = '${id}${testDescription}'; | 71 String title = '${id}${testDescription}'; |
| 72 Compiler compilerNormal = await measure( | 72 Compiler compilerNormal = await measure( |
| 73 title, 'compile normal', () async { | 73 title, 'compile normal', () async { |
| 74 Compiler compilerNormal = compilerFor( | 74 Compiler compilerNormal = compilerFor( |
| 75 memorySourceFiles: sourceFiles, | 75 memorySourceFiles: sourceFiles, |
| 76 options: [Flags.analyzeOnly]); | 76 options: [Flags.analyzeOnly]); |
| 77 compilerNormal.resolution.retainCachesForTesting = true; | 77 compilerNormal.resolution.retainCachesForTesting = true; |
| 78 await compilerNormal.run(entryPoint); | 78 await compilerNormal.run(entryPoint); |
| 79 compilerNormal.phase = Compiler.PHASE_DONE_RESOLVING; | 79 compilerNormal.phase = Compiler.PHASE_DONE_RESOLVING; |
| 80 compilerNormal.world.populate(); | 80 compilerNormal.openWorld.populate(); |
| 81 compilerNormal.backend.onResolutionComplete(); | 81 compilerNormal.backend.onResolutionComplete(); |
| 82 compilerNormal.deferredLoadTask.onResolutionComplete( | 82 compilerNormal.deferredLoadTask.onResolutionComplete( |
| 83 compilerNormal.mainFunction); | 83 compilerNormal.mainFunction); |
| 84 return compilerNormal; | 84 return compilerNormal; |
| 85 }); | 85 }); |
| 86 | 86 |
| 87 Compiler compilerDeserialized = await measure( | 87 Compiler compilerDeserialized = await measure( |
| 88 title, 'compile deserialized', () async { | 88 title, 'compile deserialized', () async { |
| 89 Compiler compilerDeserialized = compilerFor( | 89 Compiler compilerDeserialized = compilerFor( |
| 90 memorySourceFiles: sourceFiles, | 90 memorySourceFiles: sourceFiles, |
| 91 resolutionInputs: resolutionInputs, | 91 resolutionInputs: resolutionInputs, |
| 92 options: [Flags.analyzeOnly]); | 92 options: [Flags.analyzeOnly]); |
| 93 compilerDeserialized.resolution.retainCachesForTesting = true; | 93 compilerDeserialized.resolution.retainCachesForTesting = true; |
| 94 await compilerDeserialized.run(entryPoint); | 94 await compilerDeserialized.run(entryPoint); |
| 95 compilerDeserialized.phase = Compiler.PHASE_DONE_RESOLVING; | 95 compilerDeserialized.phase = Compiler.PHASE_DONE_RESOLVING; |
| 96 compilerDeserialized.world.populate(); | 96 compilerDeserialized.openWorld.populate(); |
| 97 compilerDeserialized.backend.onResolutionComplete(); | 97 compilerDeserialized.backend.onResolutionComplete(); |
| 98 compilerDeserialized.deferredLoadTask.onResolutionComplete( | 98 compilerDeserialized.deferredLoadTask.onResolutionComplete( |
| 99 compilerDeserialized.mainFunction); | 99 compilerDeserialized.mainFunction); |
| 100 return compilerDeserialized; | 100 return compilerDeserialized; |
| 101 }); | 101 }); |
| 102 | 102 |
| 103 return measure(title, 'check models', () async { | 103 return measure(title, 'check models', () async { |
| 104 checkAllImpacts( | 104 checkAllImpacts( |
| 105 compilerNormal, compilerDeserialized, | 105 compilerNormal, compilerDeserialized, |
| 106 verbose: verbose); | 106 verbose: verbose); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 133 areElementsEquivalent, | 133 areElementsEquivalent, |
| 134 onSameElement: (a, b) { | 134 onSameElement: (a, b) { |
| 135 checkElements( | 135 checkElements( |
| 136 compilerNormal, compilerDeserialized, a, b, verbose: verbose); | 136 compilerNormal, compilerDeserialized, a, b, verbose: verbose); |
| 137 }, | 137 }, |
| 138 verbose: verbose); | 138 verbose: verbose); |
| 139 | 139 |
| 140 checkClassHierarchyNodes( | 140 checkClassHierarchyNodes( |
| 141 compilerNormal, | 141 compilerNormal, |
| 142 compilerDeserialized, | 142 compilerDeserialized, |
| 143 compilerNormal.world.getClassHierarchyNode( | 143 compilerNormal.closedWorld.getClassHierarchyNode( |
| 144 compilerNormal.coreClasses.objectClass), | 144 compilerNormal.coreClasses.objectClass), |
| 145 compilerDeserialized.world.getClassHierarchyNode( | 145 compilerDeserialized.closedWorld.getClassHierarchyNode( |
| 146 compilerDeserialized.coreClasses.objectClass), | 146 compilerDeserialized.coreClasses.objectClass), |
| 147 verbose: verbose); | 147 verbose: verbose); |
| 148 | 148 |
| 149 Expect.equals(compilerNormal.enabledInvokeOn, | 149 Expect.equals(compilerNormal.enabledInvokeOn, |
| 150 compilerDeserialized.enabledInvokeOn, | 150 compilerDeserialized.enabledInvokeOn, |
| 151 "Compiler.enabledInvokeOn mismatch"); | 151 "Compiler.enabledInvokeOn mismatch"); |
| 152 Expect.equals(compilerNormal.enabledFunctionApply, | 152 Expect.equals(compilerNormal.enabledFunctionApply, |
| 153 compilerDeserialized.enabledFunctionApply, | 153 compilerDeserialized.enabledFunctionApply, |
| 154 "Compiler.enabledFunctionApply mismatch"); | 154 "Compiler.enabledFunctionApply mismatch"); |
| 155 Expect.equals(compilerNormal.enabledRuntimeType, | 155 Expect.equals(compilerNormal.enabledRuntimeType, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 checkElementOutputUnits(compiler1, compiler2, element1, element2); | 280 checkElementOutputUnits(compiler1, compiler2, element1, element2); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void checkMixinUses( | 283 void checkMixinUses( |
| 284 Compiler compiler1, Compiler compiler2, | 284 Compiler compiler1, Compiler compiler2, |
| 285 ClassElement class1, ClassElement class2, | 285 ClassElement class1, ClassElement class2, |
| 286 {bool verbose: false}) { | 286 {bool verbose: false}) { |
| 287 | 287 |
| 288 checkSets( | 288 checkSets( |
| 289 compiler1.world.mixinUsesOf(class1), | 289 compiler1.closedWorld.mixinUsesOf(class1), |
| 290 compiler2.world.mixinUsesOf(class2), | 290 compiler2.closedWorld.mixinUsesOf(class2), |
| 291 "Mixin uses of $class1 vs $class2", | 291 "Mixin uses of $class1 vs $class2", |
| 292 areElementsEquivalent, | 292 areElementsEquivalent, |
| 293 verbose: verbose); | 293 verbose: verbose); |
| 294 | 294 |
| 295 } | 295 } |
| 296 | 296 |
| 297 void checkClassHierarchyNodes( | 297 void checkClassHierarchyNodes( |
| 298 Compiler compiler1, | 298 Compiler compiler1, |
| 299 Compiler compiler2, | 299 Compiler compiler2, |
| 300 ClassHierarchyNode node1, ClassHierarchyNode node2, | 300 ClassHierarchyNode node1, ClassHierarchyNode node2, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 324 checkClassHierarchyNodes(compiler1, compiler2, | 324 checkClassHierarchyNodes(compiler1, compiler2, |
| 325 child, other, verbose: verbose); | 325 child, other, verbose: verbose); |
| 326 found = true; | 326 found = true; |
| 327 break; | 327 break; |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 if (!found) { | 330 if (!found) { |
| 331 if (child.isInstantiated) { | 331 if (child.isInstantiated) { |
| 332 print('Missing subclass ${child.cls} of ${node1.cls} ' | 332 print('Missing subclass ${child.cls} of ${node1.cls} ' |
| 333 'in ${node2.directSubclasses}'); | 333 'in ${node2.directSubclasses}'); |
| 334 print(compiler1.world.dump( | 334 print(compiler1.closedWorld.dump( |
| 335 verbose ? compiler1.coreClasses.objectClass : node1.cls)); | 335 verbose ? compiler1.coreClasses.objectClass : node1.cls)); |
| 336 print(compiler2.world.dump( | 336 print(compiler2.closedWorld.dump( |
| 337 verbose ? compiler2.coreClasses.objectClass : node2.cls)); | 337 verbose ? compiler2.coreClasses.objectClass : node2.cls)); |
| 338 } | 338 } |
| 339 Expect.isFalse(child.isInstantiated, | 339 Expect.isFalse(child.isInstantiated, |
| 340 'Missing subclass ${child.cls} of ${node1.cls} in ' | 340 'Missing subclass ${child.cls} of ${node1.cls} in ' |
| 341 '${node2.directSubclasses}'); | 341 '${node2.directSubclasses}'); |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 checkMixinUses(compiler1, compiler2, node1.cls, node2.cls, verbose: verbose); | 344 checkMixinUses(compiler1, compiler2, node1.cls, node2.cls, verbose: verbose); |
| 345 } | 345 } |
| 346 | 346 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 OutputUnit outputUnit1, OutputUnit outputUnit2, String message) { | 407 OutputUnit outputUnit1, OutputUnit outputUnit2, String message) { |
| 408 if (outputUnit1 == null && outputUnit2 == null) return; | 408 if (outputUnit1 == null && outputUnit2 == null) return; |
| 409 check(outputUnit1, outputUnit2, | 409 check(outputUnit1, outputUnit2, |
| 410 'OutputUnit.isMainOutput $message', | 410 'OutputUnit.isMainOutput $message', |
| 411 outputUnit1.isMainOutput, outputUnit2.isMainOutput); | 411 outputUnit1.isMainOutput, outputUnit2.isMainOutput); |
| 412 checkSetEquivalence(outputUnit1, outputUnit2, | 412 checkSetEquivalence(outputUnit1, outputUnit2, |
| 413 'OutputUnit.imports $message', | 413 'OutputUnit.imports $message', |
| 414 outputUnit1.imports, outputUnit2.imports, | 414 outputUnit1.imports, outputUnit2.imports, |
| 415 (a, b) => areElementsEquivalent(a.declaration, b.declaration)); | 415 (a, b) => areElementsEquivalent(a.declaration, b.declaration)); |
| 416 } | 416 } |
| OLD | NEW |