OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // Subset of dead_entry_through_mirrors_test that is not affected by | 5 // Subset of dead_entry_through_mirrors_test that is not affected by |
6 // tree-shaking. This subset can be run in the VM. | 6 // tree-shaking. This subset can be run in the VM. |
7 library live_entry_through_mirrors_used_test; | 7 library live_entry_through_mirrors_used_test; |
8 | 8 |
9 import 'package:lookup_map/lookup_map.dart'; | 9 import 'package:lookup_map/lookup_map.dart'; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
11 | 11 |
12 @MirrorsUsed(targets: const [A]) | 12 @MirrorsUsed(targets: const [A]) |
13 import 'dart:mirrors'; | 13 import 'dart:mirrors'; |
14 | 14 |
15 class A{} | 15 class A {} |
16 class B{} | 16 |
| 17 class B {} |
| 18 |
17 const map = const LookupMap(const [ | 19 const map = const LookupMap(const [ |
18 A, "the-text-for-A", | 20 A, |
19 B, "the-text-for-B", | 21 "the-text-for-A", |
| 22 B, |
| 23 "the-text-for-B", |
20 ]); | 24 ]); |
21 | 25 |
22 main() { | 26 main() { |
23 // `A` is included by @MirrorsUsed, so its entry is retained too. | 27 // `A` is included by @MirrorsUsed, so its entry is retained too. |
24 LibraryMirror lib = currentMirrorSystem().findLibrary( | 28 LibraryMirror lib = |
25 #live_entry_through_mirrors_used_test); | 29 currentMirrorSystem().findLibrary(#live_entry_through_mirrors_used_test); |
26 ClassMirror aClass = lib.declarations[#A]; | 30 ClassMirror aClass = lib.declarations[#A]; |
27 Expect.equals(map[aClass.reflectedType], "the-text-for-A"); | 31 Expect.equals(map[aClass.reflectedType], "the-text-for-A"); |
28 } | 32 } |
OLD | NEW |