OLD | NEW |
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"; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 Expect.isFalse( | 120 Expect.isFalse( |
121 compiler.backend.isAccessibleByReflection(member), '$member'); | 121 compiler.backend.isAccessibleByReflection(member), '$member'); |
122 } | 122 } |
123 }); | 123 }); |
124 } | 124 } |
125 | 125 |
126 int metadataCount = 0; | 126 int metadataCount = 0; |
127 Set<ConstantValue> compiledConstants = backend.constants.compiledConstants; | 127 Set<ConstantValue> compiledConstants = backend.constants.compiledConstants; |
128 // Make sure that most of the metadata constants aren't included in the | 128 // Make sure that most of the metadata constants aren't included in the |
129 // generated code. | 129 // generated code. |
130 backend.processMetadata(compiler.enqueuer.resolution.processedElements, | 130 backend.processMetadata(compiler.enqueuer.resolution.processedEntities, |
131 (metadata) { | 131 (metadata) { |
132 ConstantValue constant = | 132 ConstantValue constant = |
133 backend.constants.getConstantValueForMetadata(metadata); | 133 backend.constants.getConstantValueForMetadata(metadata); |
134 Expect.isFalse( | 134 Expect.isFalse( |
135 compiledConstants.contains(constant), constant.toStructuredText()); | 135 compiledConstants.contains(constant), constant.toStructuredText()); |
136 metadataCount++; | 136 metadataCount++; |
137 }); | 137 }); |
138 | 138 |
139 // There should at least be one metadata constant: | 139 // There should at least be one metadata constant: |
140 // 1. The constructed constant for 'MirrorsUsed'. | 140 // 1. The constructed constant for 'MirrorsUsed'. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 library lib; | 180 library lib; |
181 | 181 |
182 import 'dart:mirrors'; | 182 import 'dart:mirrors'; |
183 | 183 |
184 useReflect(type) { | 184 useReflect(type) { |
185 print(new Symbol('Foo')); | 185 print(new Symbol('Foo')); |
186 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 186 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
187 } | 187 } |
188 """, | 188 """, |
189 }; | 189 }; |
OLD | NEW |