| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 for (var element in generatedCode) { | 52 for (var element in generatedCode) { |
| 53 print(element); | 53 print(element); |
| 54 } | 54 } |
| 55 print(''); | 55 print(''); |
| 56 | 56 |
| 57 // This assertion can fail for two reasons: | 57 // This assertion can fail for two reasons: |
| 58 // 1. Too many elements retained for reflection. | 58 // 1. Too many elements retained for reflection. |
| 59 // 2. Some code was refactored, and there are more methods. | 59 // 2. Some code was refactored, and there are more methods. |
| 60 // Either situation could be problematic, but in situation 2, it is often | 60 // Either situation could be problematic, but in situation 2, it is often |
| 61 // acceptable to increase [expectedMethodCount] a little. | 61 // acceptable to increase [expectedMethodCount] a little. |
| 62 int expectedMethodCount = 326; | 62 int expectedMethodCount = 327; |
| 63 Expect.isTrue( | 63 Expect.isTrue( |
| 64 generatedCode.length <= expectedMethodCount, | 64 generatedCode.length <= expectedMethodCount, |
| 65 'Too many compiled methods: ' | 65 'Too many compiled methods: ' |
| 66 '${generatedCode.length} > $expectedMethodCount'); | 66 '${generatedCode.length} > $expectedMethodCount'); |
| 67 | 67 |
| 68 // The following names should be retained: | 68 // The following names should be retained: |
| 69 List expectedNames = [ | 69 List expectedNames = [ |
| 70 'Foo', // The name of class Foo. | 70 'Foo', // The name of class Foo. |
| 71 r'Foo$', // The name of class Foo's constructor. | 71 r'Foo$', // The name of class Foo's constructor. |
| 72 'Foo_staticMethod', // The name of Foo.staticMethod. | 72 'Foo_staticMethod', // The name of Foo.staticMethod. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 library lib; | 147 library lib; |
| 148 | 148 |
| 149 import 'dart:mirrors'; | 149 import 'dart:mirrors'; |
| 150 | 150 |
| 151 useReflect(type) { | 151 useReflect(type) { |
| 152 print(new Symbol('Foo')); | 152 print(new Symbol('Foo')); |
| 153 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 153 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
| 154 } | 154 } |
| 155 """, | 155 """, |
| 156 }; | 156 }; |
| OLD | NEW |