| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 Set recordedNames = new Set() | 102 Set recordedNames = new Set() |
| 103 ..addAll(fullEmitter.recordedMangledNames) | 103 ..addAll(fullEmitter.recordedMangledNames) |
| 104 ..addAll(fullEmitter.mangledFieldNames.keys) | 104 ..addAll(fullEmitter.mangledFieldNames.keys) |
| 105 ..addAll(fullEmitter.mangledGlobalFieldNames.keys); | 105 ..addAll(fullEmitter.mangledGlobalFieldNames.keys); |
| 106 Expect.setEquals(new Set.from(expectedNames), recordedNames); | 106 Expect.setEquals(new Set.from(expectedNames), recordedNames); |
| 107 | 107 |
| 108 for (var library in compiler.libraryLoader.libraries) { | 108 for (var library in compiler.libraryLoader.libraries) { |
| 109 library.forEachLocalMember((member) { | 109 library.forEachLocalMember((member) { |
| 110 if (library == compiler.mainApp && member.name == 'Foo') { | 110 if (library == compiler.mainApp && member.name == 'Foo') { |
| 111 Expect.isTrue( | 111 Expect.isTrue( |
| 112 compiler.backend.isAccessibleByReflection(member), '$member'); | 112 compiler.backend.mirrorsData.isAccessibleByReflection(member), |
| 113 '$member'); |
| 113 member.forEachLocalMember((classMember) { | 114 member.forEachLocalMember((classMember) { |
| 114 Expect.isTrue( | 115 Expect.isTrue( |
| 115 compiler.backend.isAccessibleByReflection(classMember), | 116 compiler.backend.mirrorsData |
| 117 .isAccessibleByReflection(classMember), |
| 116 '$classMember'); | 118 '$classMember'); |
| 117 }); | 119 }); |
| 118 } else { | 120 } else { |
| 119 Expect.isFalse( | 121 Expect.isFalse( |
| 120 compiler.backend.isAccessibleByReflection(member), '$member'); | 122 compiler.backend.mirrorsData.isAccessibleByReflection(member), |
| 123 '$member'); |
| 121 } | 124 } |
| 122 }); | 125 }); |
| 123 } | 126 } |
| 124 | 127 |
| 125 int metadataCount = 0; | 128 int metadataCount = 0; |
| 126 Set<ConstantValue> compiledConstants = backend.constants.compiledConstants; | 129 Set<ConstantValue> compiledConstants = backend.constants.compiledConstants; |
| 127 // Make sure that most of the metadata constants aren't included in the | 130 // Make sure that most of the metadata constants aren't included in the |
| 128 // generated code. | 131 // generated code. |
| 129 backend.processMetadata(compiler.enqueuer.resolution.processedEntities, | 132 backend.processMetadata(compiler.enqueuer.resolution.processedEntities, |
| 130 (metadata) { | 133 (metadata) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 library lib; | 182 library lib; |
| 180 | 183 |
| 181 import 'dart:mirrors'; | 184 import 'dart:mirrors'; |
| 182 | 185 |
| 183 useReflect(type) { | 186 useReflect(type) { |
| 184 print(new Symbol('Foo')); | 187 print(new Symbol('Foo')); |
| 185 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 188 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
| 186 } | 189 } |
| 187 """, | 190 """, |
| 188 }; | 191 }; |
| OLD | NEW |