OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 library test.library_declarations_test; | |
ahe
2014/08/04 09:19:40
For consistency, consider changing name to match f
| |
6 | |
7 @MirrorsUsed(targets: "test.library_declarations_test") | |
ahe
2014/08/04 09:19:40
Ditto.
| |
8 import 'dart:mirrors'; | |
9 import 'package:expect/expect.dart'; | |
10 | |
11 class A { | |
12 static foo() => 499; | |
13 } | |
14 | |
15 main() { | |
16 // Avoid inlining of nested closure. | |
17 var targetLibrary = const Symbol("test.library_declarations_test"); | |
18 confuse(x) { | |
19 if (new DateTime.now().millisecondsSinceEpoch == 0) confuse(x + 1); | |
20 if (x != 0) { | |
21 Expect.fail("must be 0"); | |
22 } | |
23 var keys = currentMirrorSystem().findLibrary(targetLibrary).declarations | |
24 .keys.toList(); | |
25 Expect.equals(2, keys.length); | |
26 Expect.isTrue(#A == keys[0] || #main == keys[0]); | |
27 Expect.isTrue(#A == keys[1] || #main == keys[1]); | |
28 Expect.isTrue(keys[0] != keys[1]); | |
29 } | |
30 confuse(0); | |
31 } | |
OLD | NEW |