| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 void main() { | 47 void main() { |
| 48 asyncTest(() async { | 48 asyncTest(() async { |
| 49 var result = await runCompiler( | 49 var result = await runCompiler( |
| 50 memorySourceFiles: MEMORY_SOURCE_FILES, | 50 memorySourceFiles: MEMORY_SOURCE_FILES, |
| 51 diagnosticHandler: new LegacyCompilerDiagnostics(expectOnlyVerboseInfo), | 51 diagnosticHandler: new LegacyCompilerDiagnostics(expectOnlyVerboseInfo), |
| 52 options: ['--enable-experimental-mirrors']); | 52 options: ['--enable-experimental-mirrors']); |
| 53 CompilerImpl compiler = result.compiler; | 53 CompilerImpl compiler = result.compiler; |
| 54 JavaScriptBackend backend = compiler.backend; | 54 JavaScriptBackend backend = compiler.backend; |
| 55 print(''); | 55 print(''); |
| 56 List generatedCode = Elements.sortedByPosition(backend.generatedCode.keys); | 56 List generatedCode = |
| 57 Elements.sortedByPosition(new List.from(backend.generatedCode.keys)); |
| 57 for (var element in generatedCode) { | 58 for (var element in generatedCode) { |
| 58 print(element); | 59 print(element); |
| 59 } | 60 } |
| 60 print(''); | 61 print(''); |
| 61 | 62 |
| 62 // This assertion can fail for two reasons: | 63 // This assertion can fail for two reasons: |
| 63 // 1. Too many elements retained for reflection. | 64 // 1. Too many elements retained for reflection. |
| 64 // 2. Some code was refactored, and there are more methods. | 65 // 2. Some code was refactored, and there are more methods. |
| 65 // Either situation could be problematic, but in situation 2, it is often | 66 // Either situation could be problematic, but in situation 2, it is often |
| 66 // acceptable to increase [expectedMethodCount] a little. | 67 // acceptable to increase [expectedMethodCount] a little. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 library lib; | 200 library lib; |
| 200 | 201 |
| 201 import 'dart:mirrors'; | 202 import 'dart:mirrors'; |
| 202 | 203 |
| 203 useReflect(type) { | 204 useReflect(type) { |
| 204 print(new Symbol('Foo')); | 205 print(new Symbol('Foo')); |
| 205 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 206 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
| 206 } | 207 } |
| 207 """, | 208 """, |
| 208 }; | 209 }; |
| OLD | NEW |