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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 for (var element in generatedCode) { | 56 for (var element in generatedCode) { |
57 print(element); | 57 print(element); |
58 } | 58 } |
59 print(''); | 59 print(''); |
60 | 60 |
61 // This assertion can fail for two reasons: | 61 // This assertion can fail for two reasons: |
62 // 1. Too many elements retained for reflection. | 62 // 1. Too many elements retained for reflection. |
63 // 2. Some code was refactored, and there are more methods. | 63 // 2. Some code was refactored, and there are more methods. |
64 // Either situation could be problematic, but in situation 2, it is often | 64 // Either situation could be problematic, but in situation 2, it is often |
65 // acceptable to increase [expectedMethodCount] a little. | 65 // acceptable to increase [expectedMethodCount] a little. |
66 int expectedMethodCount = 476; | 66 int expectedMethodCount = 477; |
67 Expect.isTrue( | 67 Expect.isTrue( |
68 generatedCode.length <= expectedMethodCount, | 68 generatedCode.length <= expectedMethodCount, |
69 'Too many compiled methods: ' | 69 'Too many compiled methods: ' |
70 '${generatedCode.length} > $expectedMethodCount'); | 70 '${generatedCode.length} > $expectedMethodCount'); |
71 | 71 |
72 // The following names should be retained: | 72 // The following names should be retained: |
73 List expectedNames = [ | 73 List expectedNames = [ |
74 'Foo', // The name of class Foo. | 74 'Foo', // The name of class Foo. |
75 r'Foo$', // The name of class Foo's constructor. | 75 r'Foo$', // The name of class Foo's constructor. |
76 r'get$field' | 76 r'get$field' |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 library lib; | 182 library lib; |
183 | 183 |
184 import 'dart:mirrors'; | 184 import 'dart:mirrors'; |
185 | 185 |
186 useReflect(type) { | 186 useReflect(type) { |
187 print(new Symbol('Foo')); | 187 print(new Symbol('Foo')); |
188 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 188 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
189 } | 189 } |
190 """, | 190 """, |
191 }; | 191 }; |
OLD | NEW |