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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 r'Foo$', // The name of class Foo's constructor. | 81 r'Foo$', // The name of class Foo's constructor. |
82 r'get$field']; // The (getter) name of Foo.field. | 82 r'get$field']; // The (getter) name of Foo.field. |
83 // TODO(ahe): Check for the following names, currently they are not being | 83 // TODO(ahe): Check for the following names, currently they are not being |
84 // recorded correctly, but are being emitted. | 84 // recorded correctly, but are being emitted. |
85 [ | 85 [ |
86 'Foo_staticMethod', // The name of Foo.staticMethod. | 86 'Foo_staticMethod', // The name of Foo.staticMethod. |
87 r'instanceMethod$0']; // The name of Foo.instanceMethod. | 87 r'instanceMethod$0']; // The name of Foo.instanceMethod. |
88 | 88 |
89 // We always include the names of some native classes. | 89 // We always include the names of some native classes. |
90 List<Element> nativeClasses = [ | 90 List<Element> nativeClasses = [ |
91 compiler.intClass, compiler.doubleClass, compiler.numClass, | 91 compiler.coreClasses.intClass, |
92 compiler.stringClass, compiler.boolClass, compiler.nullClass, | 92 compiler.coreClasses.doubleClass, |
93 compiler.listClass | 93 compiler.coreClasses.numClass, |
| 94 compiler.coreClasses.stringClass, |
| 95 compiler.coreClasses.boolClass, |
| 96 compiler.coreClasses.nullClass, |
| 97 compiler.coreClasses.listClass |
94 ]; | 98 ]; |
95 JavaScriptBackend backend = compiler.backend; | 99 JavaScriptBackend backend = compiler.backend; |
96 Iterable<String> nativeNames = nativeClasses.map(backend.namer.className); | 100 Iterable<String> nativeNames = nativeClasses.map(backend.namer.className); |
97 expectedNames = expectedNames.map(backend.namer.asName).toList(); | 101 expectedNames = expectedNames.map(backend.namer.asName).toList(); |
98 expectedNames.addAll(nativeNames); | 102 expectedNames.addAll(nativeNames); |
99 | 103 |
100 // Mirrors only work in the full emitter. We can thus be certain that the | 104 // Mirrors only work in the full emitter. We can thus be certain that the |
101 // emitter is the full emitter. | 105 // emitter is the full emitter. |
102 full.Emitter fullEmitter = backend.emitter.emitter; | 106 full.Emitter fullEmitter = backend.emitter.emitter; |
103 Set recordedNames = new Set() | 107 Set recordedNames = new Set() |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 library lib; | 181 library lib; |
178 | 182 |
179 import 'dart:mirrors'; | 183 import 'dart:mirrors'; |
180 | 184 |
181 useReflect(type) { | 185 useReflect(type) { |
182 print(new Symbol('Foo')); | 186 print(new Symbol('Foo')); |
183 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 187 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
184 } | 188 } |
185 """, | 189 """, |
186 }; | 190 }; |
OLD | NEW |