| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_resolved_ast_test; | 5 library dart2js.serialization_resolved_ast_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:compiler/src/commandline_options.dart'; | 9 import 'package:compiler/src/commandline_options.dart'; |
| 10 import 'package:compiler/src/compiler.dart'; | 10 import 'package:compiler/src/compiler.dart'; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 Compiler compilerDeserialized = compilerFor( | 49 Compiler compilerDeserialized = compilerFor( |
| 50 memorySourceFiles: serializedData.toMemorySourceFiles(sourceFiles), | 50 memorySourceFiles: serializedData.toMemorySourceFiles(sourceFiles), |
| 51 resolutionInputs: serializedData.toUris(), | 51 resolutionInputs: serializedData.toUris(), |
| 52 options: [Flags.analyzeAll]); | 52 options: [Flags.analyzeAll]); |
| 53 compilerDeserialized.resolution.retainCachesForTesting = true; | 53 compilerDeserialized.resolution.retainCachesForTesting = true; |
| 54 await compilerDeserialized.run(entryPoint); | 54 await compilerDeserialized.run(entryPoint); |
| 55 | 55 |
| 56 checkAllResolvedAsts(compilerNormal, compilerDeserialized, verbose: true); | 56 checkAllResolvedAsts(compilerNormal, compilerDeserialized, verbose: true); |
| 57 } | 57 } |
| 58 | |
| 59 void checkAllResolvedAsts( | |
| 60 Compiler compiler1, | |
| 61 Compiler compiler2, | |
| 62 {bool verbose: false}) { | |
| 63 checkLoadedLibraryMembers( | |
| 64 compiler1, | |
| 65 compiler2, | |
| 66 (Element member1) { | |
| 67 return member1 is ExecutableElement && | |
| 68 compiler1.resolution.hasResolvedAst(member1); | |
| 69 }, | |
| 70 checkResolvedAsts, | |
| 71 verbose: verbose); | |
| 72 } | |
| 73 | |
| 74 | |
| 75 /// Check equivalence of [impact1] and [impact2]. | |
| 76 void checkResolvedAsts(Compiler compiler1, Element member1, | |
| 77 Compiler compiler2, Element member2, | |
| 78 {bool verbose: false}) { | |
| 79 if (!compiler2.serialization.isDeserialized(member2)) { | |
| 80 return; | |
| 81 } | |
| 82 ResolvedAst resolvedAst1 = compiler1.resolution.getResolvedAst(member1); | |
| 83 ResolvedAst resolvedAst2 = compiler2.serialization.getResolvedAst(member2); | |
| 84 | |
| 85 if (resolvedAst1 == null || resolvedAst2 == null) return; | |
| 86 | |
| 87 if (verbose) { | |
| 88 print('Checking resolved asts for $member1 vs $member2'); | |
| 89 } | |
| 90 | |
| 91 testResolvedAstEquivalence( | |
| 92 resolvedAst1, resolvedAst2, const CheckStrategy()); | |
| 93 } | |
| OLD | NEW |