| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 for (var element in generatedCode) { | 53 for (var element in generatedCode) { |
| 54 print(element); | 54 print(element); |
| 55 } | 55 } |
| 56 print(''); | 56 print(''); |
| 57 | 57 |
| 58 // This assertion can fail for two reasons: | 58 // This assertion can fail for two reasons: |
| 59 // 1. Too many elements retained for reflection. | 59 // 1. Too many elements retained for reflection. |
| 60 // 2. Some code was refactored, and there are more methods. | 60 // 2. Some code was refactored, and there are more methods. |
| 61 // Either situation could be problematic, but in situation 2, it is often | 61 // Either situation could be problematic, but in situation 2, it is often |
| 62 // acceptable to increase [expectedMethodCount] a little. | 62 // acceptable to increase [expectedMethodCount] a little. |
| 63 int expectedMethodCount = 380; | 63 int expectedMethodCount = 381; |
| 64 Expect.isTrue( | 64 Expect.isTrue( |
| 65 generatedCode.length <= expectedMethodCount, | 65 generatedCode.length <= expectedMethodCount, |
| 66 'Too many compiled methods: ' | 66 'Too many compiled methods: ' |
| 67 '${generatedCode.length} > $expectedMethodCount'); | 67 '${generatedCode.length} > $expectedMethodCount'); |
| 68 | 68 |
| 69 // The following names should be retained: | 69 // The following names should be retained: |
| 70 List expectedNames = [ | 70 List expectedNames = [ |
| 71 'Foo', // The name of class Foo. | 71 'Foo', // The name of class Foo. |
| 72 r'Foo$', // The name of class Foo's constructor. | 72 r'Foo$', // The name of class Foo's constructor. |
| 73 r'get$field']; // The (getter) name of Foo.field. | 73 r'get$field']; // The (getter) name of Foo.field. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 library lib; | 163 library lib; |
| 164 | 164 |
| 165 import 'dart:mirrors'; | 165 import 'dart:mirrors'; |
| 166 | 166 |
| 167 useReflect(type) { | 167 useReflect(type) { |
| 168 print(new Symbol('Foo')); | 168 print(new Symbol('Foo')); |
| 169 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); | 169 print(MirrorSystem.getName(reflectClass(type).owner.qualifiedName)); |
| 170 } | 170 } |
| 171 """, | 171 """, |
| 172 }; | 172 }; |
| OLD | NEW |