| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 library test; | 5 library test; |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 | 8 |
| 9 @MirrorsUsed(targets: "Foo") | 9 @MirrorsUsed(targets: "Foo") |
| 10 import 'dart:mirrors'; | 10 import 'dart:mirrors'; |
| 11 | 11 |
| 12 typedef int Foo(String x); | 12 typedef int Foo(String x); |
| 13 typedef int Bar(); | 13 typedef int Bar(); |
| 14 | 14 |
| 15 main() { | 15 main() { |
| 16 LibraryMirror thisLibrary = currentMirrorSystem().findLibrary(#test); | 16 LibraryMirror thisLibrary = currentMirrorSystem().findLibrary(#test); |
| 17 | 17 |
| 18 Mirror fooMirror = thisLibrary.declarations[#Foo]; | 18 Mirror fooMirror = thisLibrary.declarations[#Foo]; |
| 19 | 19 |
| 20 Expect.isTrue(fooMirror != null, 'Foo not found.'); | 20 Expect.isTrue(fooMirror != null, 'Foo not found.'); |
| 21 Expect.isTrue(thisLibrary.declarations[#Foo] is TypedefMirror, | 21 Expect.isTrue(thisLibrary.declarations[#Foo] is TypedefMirror, |
| 22 'TypedefMirror expected, found $fooMirror'); | 22 'TypedefMirror expected, found $fooMirror'); |
| 23 | 23 |
| 24 // The following code does not currenty work on the VM, because it does not | 24 // The following code does not currently work on the VM, because it does not |
| 25 // support MirrorsUsed (see dartbug.com/16048). | 25 // support MirrorsUsed (see dartbug.com/16048). |
| 26 Mirror barMirror = thisLibrary.declarations[#Bar]; // //# 01: ok | 26 Mirror barMirror = thisLibrary.declarations[#Bar]; // //# 01: ok |
| 27 Expect.isTrue(barMirror == null, // //# 01: cont
inued | 27 Expect.isTrue(barMirror == null, // //# 01: cont
inued |
| 28 'Bar should not be emitted due to MirrorsUsed.'); //# 01: contin
ued | 28 'Bar should not be emitted due to MirrorsUsed.'); //# 01: contin
ued |
| 29 } | 29 } |
| OLD | NEW |