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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 full.Emitter fullEmitter = backend.emitter.emitter; | 106 full.Emitter fullEmitter = backend.emitter.emitter; |
107 Set recordedNames = new Set() | 107 Set recordedNames = new Set() |
108 ..addAll(fullEmitter.recordedMangledNames) | 108 ..addAll(fullEmitter.recordedMangledNames) |
109 ..addAll(fullEmitter.mangledFieldNames.keys) | 109 ..addAll(fullEmitter.mangledFieldNames.keys) |
110 ..addAll(fullEmitter.mangledGlobalFieldNames.keys); | 110 ..addAll(fullEmitter.mangledGlobalFieldNames.keys); |
111 Expect.setEquals(new Set.from(expectedNames), recordedNames); | 111 Expect.setEquals(new Set.from(expectedNames), recordedNames); |
112 | 112 |
113 for (var library in compiler.libraryLoader.libraries) { | 113 for (var library in compiler.libraryLoader.libraries) { |
114 library.forEachLocalMember((member) { | 114 library.forEachLocalMember((member) { |
115 if (member.isClass) { | 115 if (member.isClass) { |
116 if (library == compiler.mainApp && member.name == 'Foo') { | 116 if (library == |
| 117 compiler.frontendStrategy.elementEnvironment.mainLibrary && |
| 118 member.name == 'Foo') { |
117 Expect.isTrue( | 119 Expect.isTrue( |
118 compiler.backend.mirrorsData | 120 compiler.backend.mirrorsData |
119 .isClassAccessibleByReflection(member), | 121 .isClassAccessibleByReflection(member), |
120 '$member'); | 122 '$member'); |
121 member.forEachLocalMember((classMember) { | 123 member.forEachLocalMember((classMember) { |
122 Expect.isTrue( | 124 Expect.isTrue( |
123 compiler.backend.mirrorsData | 125 compiler.backend.mirrorsData |
124 .isMemberAccessibleByReflection(classMember), | 126 .isMemberAccessibleByReflection(classMember), |
125 '$classMember'); | 127 '$classMember'); |
126 }); | 128 }); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 library lib; | 207 library lib; |
206 | 208 |
207 import 'dart:mirrors'; | 209 import 'dart:mirrors'; |
208 | 210 |
209 useReflect(type) { | 211 useReflect(type) { |
210 print(new Symbol('Foo')); | 212 print(new Symbol('Foo')); |
211 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 213 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
212 } | 214 } |
213 """, | 215 """, |
214 }; | 216 }; |
OLD | NEW |