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"; |
11 | 11 |
12 import 'memory_compiler.dart' show | 12 import 'memory_compiler.dart' show |
13 runCompiler; | 13 runCompiler; |
14 | 14 |
15 import 'package:compiler/src/apiimpl.dart' show | 15 import 'package:compiler/src/apiimpl.dart' show |
16 Compiler; | 16 CompilerImpl; |
17 | 17 |
18 import 'package:compiler/src/constants/values.dart' show | 18 import 'package:compiler/src/constants/values.dart' show |
19 ConstantValue, | 19 ConstantValue, |
20 TypeConstantValue; | 20 TypeConstantValue; |
21 | 21 |
22 import 'package:compiler/src/elements/elements.dart' show | 22 import 'package:compiler/src/elements/elements.dart' show |
23 Element, | 23 Element, |
24 Elements; | 24 Elements; |
25 | 25 |
26 import 'package:compiler/src/js_backend/js_backend.dart' show | 26 import 'package:compiler/src/js_backend/js_backend.dart' show |
(...skipping 21 matching lines...) Expand all Loading... |
48 | 48 |
49 throw '$uri:$begin:$end: $kind: $message'; | 49 throw '$uri:$begin:$end: $kind: $message'; |
50 } | 50 } |
51 | 51 |
52 void main() { | 52 void main() { |
53 asyncTest(() async { | 53 asyncTest(() async { |
54 var result = await runCompiler( | 54 var result = await runCompiler( |
55 memorySourceFiles: MEMORY_SOURCE_FILES, | 55 memorySourceFiles: MEMORY_SOURCE_FILES, |
56 diagnosticHandler: new LegacyCompilerDiagnostics(expectOnlyVerboseInfo), | 56 diagnosticHandler: new LegacyCompilerDiagnostics(expectOnlyVerboseInfo), |
57 options: ['--enable-experimental-mirrors']); | 57 options: ['--enable-experimental-mirrors']); |
58 Compiler compiler = result.compiler; | 58 CompilerImpl compiler = result.compiler; |
59 print(''); | 59 print(''); |
60 List generatedCode = | 60 List generatedCode = |
61 Elements.sortedByPosition(compiler.enqueuer.codegen.generatedCode.keys); | 61 Elements.sortedByPosition(compiler.enqueuer.codegen.generatedCode.keys); |
62 for (var element in generatedCode) { | 62 for (var element in generatedCode) { |
63 print(element); | 63 print(element); |
64 } | 64 } |
65 print(''); | 65 print(''); |
66 | 66 |
67 // This assertion can fail for two reasons: | 67 // This assertion can fail for two reasons: |
68 // 1. Too many elements retained for reflection. | 68 // 1. Too many elements retained for reflection. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 library lib; | 181 library lib; |
182 | 182 |
183 import 'dart:mirrors'; | 183 import 'dart:mirrors'; |
184 | 184 |
185 useReflect(type) { | 185 useReflect(type) { |
186 print(new Symbol('Foo')); | 186 print(new Symbol('Foo')); |
187 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 187 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
188 } | 188 } |
189 """, | 189 """, |
190 }; | 190 }; |
OLD | NEW |