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:expect/expect.dart'; | 9 import 'package:expect/expect.dart'; |
10 import 'package:compiler/src/commandline_options.dart'; | 10 import 'package:compiler/src/commandline_options.dart'; |
11 import 'package:compiler/src/common/backend_api.dart'; | 11 import 'package:compiler/src/common/backend_api.dart'; |
12 import 'package:compiler/src/common/names.dart'; | 12 import 'package:compiler/src/common/names.dart'; |
13 import 'package:compiler/src/compiler.dart'; | 13 import 'package:compiler/src/compiler.dart'; |
14 import 'package:compiler/src/elements/elements.dart'; | 14 import 'package:compiler/src/elements/elements.dart'; |
15 import 'package:compiler/src/filenames.dart'; | 15 import 'package:compiler/src/filenames.dart'; |
16 import 'package:compiler/src/serialization/equivalence.dart'; | 16 import 'package:compiler/src/serialization/equivalence.dart'; |
| 17 import 'package:compiler/src/serialization/system.dart'; |
17 import '../memory_compiler.dart'; | 18 import '../memory_compiler.dart'; |
18 import 'helper.dart'; | 19 import 'helper.dart'; |
19 import 'test_data.dart'; | 20 import 'test_data.dart'; |
20 import 'test_helper.dart'; | 21 import 'test_helper.dart'; |
21 | 22 |
22 | 23 |
23 main(List<String> args) { | 24 main(List<String> args) { |
24 Arguments arguments = new Arguments.from(args); | 25 Arguments arguments = new Arguments.from(args); |
25 asyncTest(() async { | 26 asyncTest(() async { |
26 String serializedData = await serializeDartCore(arguments: arguments); | 27 String serializedData = await serializeDartCore(arguments: arguments); |
(...skipping 18 matching lines...) Expand all Loading... |
45 Compiler compilerNormal = compilerFor( | 46 Compiler compilerNormal = compilerFor( |
46 memorySourceFiles: sourceFiles, | 47 memorySourceFiles: sourceFiles, |
47 options: [Flags.analyzeAll]); | 48 options: [Flags.analyzeAll]); |
48 compilerNormal.resolution.retainCachesForTesting = true; | 49 compilerNormal.resolution.retainCachesForTesting = true; |
49 await compilerNormal.run(entryPoint); | 50 await compilerNormal.run(entryPoint); |
50 | 51 |
51 Compiler compilerDeserialized = compilerFor( | 52 Compiler compilerDeserialized = compilerFor( |
52 memorySourceFiles: sourceFiles, | 53 memorySourceFiles: sourceFiles, |
53 options: [Flags.analyzeAll]); | 54 options: [Flags.analyzeAll]); |
54 compilerDeserialized.resolution.retainCachesForTesting = true; | 55 compilerDeserialized.resolution.retainCachesForTesting = true; |
55 deserialize(compilerDeserialized, serializedData); | 56 compilerDeserialized.serialization.deserializeFromText(serializedData); |
56 await compilerDeserialized.run(entryPoint); | 57 await compilerDeserialized.run(entryPoint); |
57 | 58 |
58 checkAllResolvedAsts(compilerNormal, compilerDeserialized, verbose: true); | 59 checkAllResolvedAsts(compilerNormal, compilerDeserialized, verbose: true); |
59 } | 60 } |
60 | 61 |
61 void checkAllResolvedAsts( | 62 void checkAllResolvedAsts( |
62 Compiler compiler1, | 63 Compiler compiler1, |
63 Compiler compiler2, | 64 Compiler compiler2, |
64 {bool verbose: false}) { | 65 {bool verbose: false}) { |
65 checkLoadedLibraryMembers( | 66 checkLoadedLibraryMembers( |
66 compiler1, | 67 compiler1, |
67 compiler2, | 68 compiler2, |
68 (Element member1) { | 69 (Element member1) { |
69 return member1 is ExecutableElement && | 70 return member1 is ExecutableElement && |
70 compiler1.resolution.hasResolvedAst(member1); | 71 compiler1.resolution.hasResolvedAst(member1); |
71 }, | 72 }, |
72 checkResolvedAsts, | 73 checkResolvedAsts, |
73 verbose: verbose); | 74 verbose: verbose); |
74 } | 75 } |
75 | 76 |
76 | 77 |
77 /// Check equivalence of [impact1] and [impact2]. | 78 /// Check equivalence of [impact1] and [impact2]. |
78 void checkResolvedAsts(Compiler compiler1, Element member1, | 79 void checkResolvedAsts(Compiler compiler1, Element member1, |
79 Compiler compiler2, Element member2, | 80 Compiler compiler2, Element member2, |
80 {bool verbose: false}) { | 81 {bool verbose: false}) { |
81 ResolvedAst resolvedAst1 = compiler1.resolution.getResolvedAst(member1); | 82 ResolvedAst resolvedAst1 = compiler1.resolution.getResolvedAst(member1); |
82 ResolvedAst resolvedAst2 = | 83 ResolvedAst resolvedAst2 = |
83 compiler2.serialization.deserializer.getResolvedAst(member2); | 84 compiler2.serialization.system.getResolvedAst(member2); |
84 | 85 |
85 if (resolvedAst1 == null || resolvedAst2 == null) return; | 86 if (resolvedAst1 == null || resolvedAst2 == null) return; |
86 | 87 |
87 if (verbose) { | 88 if (verbose) { |
88 print('Checking resolved asts for $member1 vs $member2'); | 89 print('Checking resolved asts for $member1 vs $member2'); |
89 } | 90 } |
90 | 91 |
91 testResolvedAstEquivalence( | 92 testResolvedAstEquivalence( |
92 resolvedAst1, resolvedAst2, const CheckStrategy()); | 93 resolvedAst1, resolvedAst2, const CheckStrategy()); |
93 } | 94 } |
OLD | NEW |