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

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

Issue 2748383003: Split MirrorsAnalysis (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « tests/compiler/dart2js/mirror_tree_shaking_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /// Test that the @MirrorsUsed annotation suppress hints and that only 5 /// Test that the @MirrorsUsed annotation suppress hints and that only
6 /// requested elements are retained for reflection. 6 /// requested elements are retained for reflection.
7 library dart2js.test.mirrors_used_test; 7 library dart2js.test.mirrors_used_test;
8 8
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 import "package:async_helper/async_helper.dart"; 10 import "package:async_helper/async_helper.dart";
11 11
12 import 'memory_compiler.dart' show runCompiler; 12 import 'memory_compiler.dart' show runCompiler;
13 13
14 import 'package:compiler/src/apiimpl.dart' show CompilerImpl; 14 import 'package:compiler/src/apiimpl.dart' show CompilerImpl;
15 15
16 import 'package:compiler/src/constants/values.dart' 16 import 'package:compiler/src/constants/values.dart'
17 show ConstantValue, TypeConstantValue; 17 show ConstantValue, TypeConstantValue;
18 18
19 import 'package:compiler/src/elements/elements.dart' show Element, Elements; 19 import 'package:compiler/src/elements/elements.dart' show Element, Elements;
20 20
21 import 'package:compiler/src/js_backend/js_backend.dart' show JavaScriptBackend; 21 import 'package:compiler/src/js_backend/js_backend.dart' show JavaScriptBackend;
22 import 'package:compiler/src/js_backend/mirrors_analysis.dart';
22 23
23 import 'package:compiler/src/js_emitter/full_emitter/emitter.dart' as full 24 import 'package:compiler/src/js_emitter/full_emitter/emitter.dart' as full
24 show Emitter; 25 show Emitter;
25 26
26 import 'package:compiler/src/old_to_new_api.dart' 27 import 'package:compiler/src/old_to_new_api.dart'
27 show LegacyCompilerDiagnostics; 28 show LegacyCompilerDiagnostics;
28 29
29 void expectOnlyVerboseInfo(Uri uri, int begin, int end, String message, kind) { 30 void expectOnlyVerboseInfo(Uri uri, int begin, int end, String message, kind) {
30 if (kind.name == 'verbose info') { 31 if (kind.name == 'verbose info') {
31 print(message); 32 print(message);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 compiler.backend.mirrorsData.isAccessibleByReflection(member), 123 compiler.backend.mirrorsData.isAccessibleByReflection(member),
123 '$member'); 124 '$member');
124 } 125 }
125 }); 126 });
126 } 127 }
127 128
128 int metadataCount = 0; 129 int metadataCount = 0;
129 Set<ConstantValue> compiledConstants = backend.constants.compiledConstants; 130 Set<ConstantValue> compiledConstants = backend.constants.compiledConstants;
130 // Make sure that most of the metadata constants aren't included in the 131 // Make sure that most of the metadata constants aren't included in the
131 // generated code. 132 // generated code.
132 backend.mirrorsAnalysis.processMetadata( 133 MirrorsResolutionAnalysisImpl mirrorsResolutionAnalysis =
134 backend.mirrorsResolutionAnalysis;
135 mirrorsResolutionAnalysis.processMetadata(
133 compiler.enqueuer.resolution.processedEntities, (metadata) { 136 compiler.enqueuer.resolution.processedEntities, (metadata) {
134 ConstantValue constant = 137 ConstantValue constant =
135 backend.constants.getConstantValueForMetadata(metadata); 138 backend.constants.getConstantValueForMetadata(metadata);
136 Expect.isFalse( 139 Expect.isFalse(
137 compiledConstants.contains(constant), constant.toStructuredText()); 140 compiledConstants.contains(constant), constant.toStructuredText());
138 metadataCount++; 141 metadataCount++;
139 }); 142 });
140 143
141 // There should at least be one metadata constant: 144 // There should at least be one metadata constant:
142 // 1. The constructed constant for 'MirrorsUsed'. 145 // 1. The constructed constant for 'MirrorsUsed'.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 library lib; 185 library lib;
183 186
184 import 'dart:mirrors'; 187 import 'dart:mirrors';
185 188
186 useReflect(type) { 189 useReflect(type) {
187 print(new Symbol('Foo')); 190 print(new Symbol('Foo'));
188 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); 191 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName));
189 } 192 }
190 """, 193 """,
191 }; 194 };
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/mirror_tree_shaking_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698