Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: tests/compiler/dart2js/serialization_impact_test.dart

Issue 1856953003: Test closed world model after deserialization. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_impact_test; 5 library dart2js.serialization_impact_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/common/resolution.dart'; 10 import 'package:compiler/src/common/resolution.dart';
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 31
32 Future check( 32 Future check(
33 String serializedData, 33 String serializedData,
34 Uri entryPoint, 34 Uri entryPoint,
35 [Map<String, String> sourceFiles = const <String, String>{}]) async { 35 [Map<String, String> sourceFiles = const <String, String>{}]) async {
36 36
37 Compiler compilerNormal = compilerFor( 37 Compiler compilerNormal = compilerFor(
38 memorySourceFiles: sourceFiles, 38 memorySourceFiles: sourceFiles,
39 options: [Flags.analyzeOnly]); 39 options: [Flags.analyzeOnly]);
40 compilerNormal.resolution.retainCaches = true; 40 compilerNormal.resolution.retainCachesForTesting = true;
41 await compilerNormal.run(entryPoint); 41 await compilerNormal.run(entryPoint);
42 42
43 Compiler compilerDeserialized = compilerFor( 43 Compiler compilerDeserialized = compilerFor(
44 memorySourceFiles: sourceFiles, 44 memorySourceFiles: sourceFiles,
45 options: [Flags.analyzeOnly]); 45 options: [Flags.analyzeOnly]);
46 compilerDeserialized.resolution.retainCaches = true; 46 compilerDeserialized.resolution.retainCachesForTesting = true;
47 deserialize(compilerDeserialized, serializedData); 47 deserialize(compilerDeserialized, serializedData);
48 await compilerDeserialized.run(entryPoint); 48 await compilerDeserialized.run(entryPoint);
49 49
50 checkResolutionImpacts(compilerNormal, compilerDeserialized); 50 checkResolutionImpacts(compilerNormal, compilerDeserialized, verbose: true);
51 } 51 }
52 52
53 /// Check equivalence of [impact1] and [impact2]. 53 /// Check equivalence of [impact1] and [impact2].
54 void checkImpacts(Element element1, Element element2, 54 void checkImpacts(Element element1, Element element2,
55 ResolutionImpact impact1, ResolutionImpact impact2) { 55 ResolutionImpact impact1, ResolutionImpact impact2,
56 {bool verbose: false}) {
56 if (impact1 == null || impact2 == null) return; 57 if (impact1 == null || impact2 == null) return;
57 58
58 print('Checking impacts for $element1 vs $element2'); 59 if (verbose) {
60 print('Checking impacts for $element1 vs $element2');
61 }
59 62
60 testResolutionImpactEquivalence(impact1, impact2, const CheckStrategy()); 63 testResolutionImpactEquivalence(impact1, impact2, const CheckStrategy());
61 } 64 }
62 65
63 66
64 /// Check equivalence between all resolution impacts common to [compiler1] and 67 /// Check equivalence between all resolution impacts common to [compiler1] and
65 /// [compiler2]. 68 /// [compiler2].
66 void checkResolutionImpacts(Compiler compiler1, Compiler compiler2) { 69 void checkResolutionImpacts(
70 Compiler compiler1,
71 Compiler compiler2,
72 {bool verbose: false}) {
67 73
68 void checkMembers(Element member1, Element member2) { 74 void checkMembers(Element member1, Element member2) {
69 if (member1.isClass && member2.isClass) { 75 if (member1.isClass && member2.isClass) {
70 ClassElement class1 = member1; 76 ClassElement class1 = member1;
71 ClassElement class2 = member2; 77 ClassElement class2 = member2;
72 class1.forEachLocalMember((m1) { 78 class1.forEachLocalMember((m1) {
73 checkMembers(m1, class2.lookupLocalMember(m1.name)); 79 checkMembers(m1, class2.lookupLocalMember(m1.name));
74 }); 80 });
75 return; 81 return;
76 } 82 }
77 83
78 if (!compiler1.resolution.hasResolutionImpact(member1)) { 84 if (!compiler1.resolution.hasResolutionImpact(member1)) {
79 return; 85 return;
80 } 86 }
81 87
82 if (member2 == null) { 88 if (member2 == null) {
83 return; 89 return;
84 } 90 }
85 91
86 if (areElementsEquivalent(member1, member2)) { 92 if (areElementsEquivalent(member1, member2)) {
87 checkImpacts( 93 checkImpacts(
88 member1, member2, 94 member1, member2,
89 compiler1.resolution.getResolutionImpact(member1), 95 compiler1.resolution.getResolutionImpact(member1),
90 compiler2.serialization.deserializer.getResolutionImpact(member2)); 96 compiler2.serialization.deserializer.getResolutionImpact(member2),
97 verbose: verbose);
91 } 98 }
92 } 99 }
93 100
94 for (LibraryElement library1 in compiler1.libraryLoader.libraries) { 101 for (LibraryElement library1 in compiler1.libraryLoader.libraries) {
95 LibraryElement library2 = 102 LibraryElement library2 =
96 compiler2.libraryLoader.lookupLibrary(library1.canonicalUri); 103 compiler2.libraryLoader.lookupLibrary(library1.canonicalUri);
97 if (library2 != null) { 104 if (library2 != null) {
98 library1.forEachLocalMember((Element member1) { 105 library1.forEachLocalMember((Element member1) {
99 checkMembers(member1, library2.localLookup(member1.name)); 106 checkMembers(member1, library2.localLookup(member1.name));
100 }); 107 });
101 108
102 } 109 }
103 } 110 }
104 } 111 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/serialization_analysis_test.dart ('k') | tests/compiler/dart2js/serialization_model_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698