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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
69 // 2. Some code was refactored, and there are more methods. | 69 // 2. Some code was refactored, and there are more methods. |
70 // Either situation could be problematic, but in situation 2, it is often | 70 // Either situation could be problematic, but in situation 2, it is often |
71 // acceptable to increase [expectedMethodCount] a little. | 71 // acceptable to increase [expectedMethodCount] a little. |
72 int expectedMethodCount = 466; | 72 int expectedMethodCount = 432; |
73 Expect.isTrue( | 73 Expect.isTrue( |
74 generatedCode.length <= expectedMethodCount, | 74 generatedCode.length <= expectedMethodCount, |
75 'Too many compiled methods: ' | 75 'Too many compiled methods: ' |
76 '${generatedCode.length} > $expectedMethodCount'); | 76 '${generatedCode.length} > $expectedMethodCount'); |
77 | 77 |
78 // The following names should be retained: | 78 // The following names should be retained: |
79 List expectedNames = [ | 79 List expectedNames = [ |
80 'Foo', // The name of class Foo. | 80 'Foo', // The name of class Foo. |
81 r'Foo$', // The name of class Foo's constructor. | 81 r'Foo$', // The name of class Foo's constructor. |
82 r'get$field']; // The (getter) name of Foo.field. | 82 r'get$field']; // The (getter) name of Foo.field. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 library lib; | 185 library lib; |
186 | 186 |
187 import 'dart:mirrors'; | 187 import 'dart:mirrors'; |
188 | 188 |
189 useReflect(type) { | 189 useReflect(type) { |
190 print(new Symbol('Foo')); | 190 print(new Symbol('Foo')); |
191 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 191 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
192 } | 192 } |
193 """, | 193 """, |
194 }; | 194 }; |
OLD | NEW |