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

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

Issue 1870133002: Refactor serialization test files. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix 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';
11 import 'package:compiler/src/compiler.dart'; 11 import 'package:compiler/src/compiler.dart';
12 import 'package:compiler/src/elements/elements.dart'; 12 import 'package:compiler/src/elements/elements.dart';
13 import 'package:compiler/src/filenames.dart'; 13 import 'package:compiler/src/filenames.dart';
14 import 'package:compiler/src/serialization/equivalence.dart'; 14 import 'package:compiler/src/serialization/equivalence.dart';
15 import 'memory_compiler.dart'; 15 import 'memory_compiler.dart';
16 import 'serialization_helper.dart'; 16 import 'serialization_helper.dart';
17 import 'serialization_test.dart'; 17 import 'serialization_test_helper.dart';
18 18
19 main(List<String> arguments) { 19 main(List<String> arguments) {
20 asyncTest(() async { 20 asyncTest(() async {
21 String serializedData = await serializeDartCore(); 21 String serializedData = await serializeDartCore();
22 if (arguments.isNotEmpty) { 22 if (arguments.isNotEmpty) {
23 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.last)); 23 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.last));
24 await check(serializedData, entryPoint); 24 await check(serializedData, entryPoint);
25 } else { 25 } else {
26 Uri entryPoint = Uri.parse('memory:main.dart'); 26 Uri entryPoint = Uri.parse('memory:main.dart');
27 await check(serializedData, entryPoint, {'main.dart': 'main() {}'}); 27 await check(serializedData, entryPoint, {'main.dart': 'main() {}'});
(...skipping 12 matching lines...) Expand all
40 compilerNormal.resolution.retainCachesForTesting = 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.retainCachesForTesting = 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, verbose: true); 50 checkAllImpacts(compilerNormal, compilerDeserialized, verbose: true);
51 } 51 }
52
53 /// Check equivalence of [impact1] and [impact2].
54 void checkImpacts(Element element1, Element element2,
55 ResolutionImpact impact1, ResolutionImpact impact2,
56 {bool verbose: false}) {
57 if (impact1 == null || impact2 == null) return;
58
59 if (verbose) {
60 print('Checking impacts for $element1 vs $element2');
61 }
62
63 testResolutionImpactEquivalence(impact1, impact2, const CheckStrategy());
64 }
65
66
67 /// Check equivalence between all resolution impacts common to [compiler1] and
68 /// [compiler2].
69 void checkResolutionImpacts(
70 Compiler compiler1,
71 Compiler compiler2,
72 {bool verbose: false}) {
73
74 void checkMembers(Element member1, Element member2) {
75 if (member1.isClass && member2.isClass) {
76 ClassElement class1 = member1;
77 ClassElement class2 = member2;
78 class1.forEachLocalMember((m1) {
79 checkMembers(m1, class2.lookupLocalMember(m1.name));
80 });
81 return;
82 }
83
84 if (!compiler1.resolution.hasResolutionImpact(member1)) {
85 return;
86 }
87
88 if (member2 == null) {
89 return;
90 }
91
92 if (areElementsEquivalent(member1, member2)) {
93 checkImpacts(
94 member1, member2,
95 compiler1.resolution.getResolutionImpact(member1),
96 compiler2.serialization.deserializer.getResolutionImpact(member2),
97 verbose: verbose);
98 }
99 }
100
101 for (LibraryElement library1 in compiler1.libraryLoader.libraries) {
102 LibraryElement library2 =
103 compiler2.libraryLoader.lookupLibrary(library1.canonicalUri);
104 if (library2 != null) {
105 library1.forEachLocalMember((Element member1) {
106 checkMembers(member1, library2.localLookup(member1.name));
107 });
108
109 }
110 }
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