| 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 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 for (var element in generatedCode) { | 41 for (var element in generatedCode) { |
| 42 print(element); | 42 print(element); |
| 43 } | 43 } |
| 44 print(''); | 44 print(''); |
| 45 | 45 |
| 46 // This assertion can fail for two reasons: | 46 // This assertion can fail for two reasons: |
| 47 // 1. Too many elements retained for reflection. | 47 // 1. Too many elements retained for reflection. |
| 48 // 2. Some code was refactored, and there are more methods. | 48 // 2. Some code was refactored, and there are more methods. |
| 49 // Either situation could be problematic, but in situation 2, it is often | 49 // Either situation could be problematic, but in situation 2, it is often |
| 50 // acceptable to increase [expectedMethodCount] a little. | 50 // acceptable to increase [expectedMethodCount] a little. |
| 51 int expectedMethodCount = 317; | 51 int expectedMethodCount = 321; |
| 52 Expect.isTrue( | 52 Expect.isTrue( |
| 53 generatedCode.length <= expectedMethodCount, | 53 generatedCode.length <= expectedMethodCount, |
| 54 'Too many compiled methods: ' | 54 'Too many compiled methods: ' |
| 55 '${generatedCode.length} > $expectedMethodCount'); | 55 '${generatedCode.length} > $expectedMethodCount'); |
| 56 | 56 |
| 57 // The following names should be retained: | 57 // The following names should be retained: |
| 58 List expectedNames = [ | 58 List expectedNames = [ |
| 59 'Foo', // The name of class Foo. | 59 'Foo', // The name of class Foo. |
| 60 r'Foo$', // The name of class Foo's constructor. | 60 r'Foo$', // The name of class Foo's constructor. |
| 61 'Foo_staticMethod', // The name of Foo.staticMethod. | 61 'Foo_staticMethod', // The name of Foo.staticMethod. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 library lib; | 110 library lib; |
| 111 | 111 |
| 112 import 'dart:mirrors'; | 112 import 'dart:mirrors'; |
| 113 | 113 |
| 114 useReflect(type) { | 114 useReflect(type) { |
| 115 print(new Symbol('Foo')); | 115 print(new Symbol('Foo')); |
| 116 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 116 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
| 117 } | 117 } |
| 118 """, | 118 """, |
| 119 }; | 119 }; |
| OLD | NEW |