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 // Test that everything reachable from a [MirrorSystem] can be accessed. | 5 // Test that everything reachable from a [MirrorSystem] can be accessed. |
6 | 6 |
7 library test.mirrors.reader; | 7 library test.mirrors.reader; |
8 | 8 |
9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 visitClassMirror(ClassMirror mirror) { | 28 visitClassMirror(ClassMirror mirror) { |
29 super.visitClassMirror(mirror); | 29 super.visitClassMirror(mirror); |
30 Expect.isNotNull(mirror.owner); | 30 Expect.isNotNull(mirror.owner); |
31 } | 31 } |
32 | 32 |
33 bool allowUnsupported(var receiver, String tag, UnsupportedError exception) { | 33 bool allowUnsupported(var receiver, String tag, UnsupportedError exception) { |
34 if (mirrorSystemType == '_LocalMirrorSystem') { | 34 if (mirrorSystemType == '_LocalMirrorSystem') { |
35 // VM mirror system. | 35 // VM mirror system. |
| 36 if (tag.endsWith('location')) { |
| 37 return receiver is ParameterMirror; |
| 38 } |
36 } else if (mirrorSystemType == 'JsMirrorSystem') { | 39 } else if (mirrorSystemType == 'JsMirrorSystem') { |
37 // Dart2js runtime mirror system. | 40 // Dart2js runtime mirror system. |
38 if (tag.endsWith('.metadata')) { | 41 if (tag.endsWith('.metadata')) { |
39 return true;// Issue 10905. | 42 return true;// Issue 10905. |
40 } | 43 } |
41 } | 44 } |
42 return false; | 45 return false; |
43 } | 46 } |
44 | 47 |
45 bool expectUnsupported(var receiver, String tag, UnsupportedError exception) { | 48 bool expectUnsupported(var receiver, String tag, UnsupportedError exception) { |
46 // [DeclarationMirror.location] is intentionally not supported in runtime | 49 // [DeclarationMirror.location] is intentionally not supported in runtime |
47 // mirrors. | 50 // mirrors. |
48 | 51 |
49 if (mirrorSystemType == '_LocalMirrorSystem') { | 52 if (mirrorSystemType == '_LocalMirrorSystem') { |
50 // VM mirror system. | 53 // VM mirror system. |
51 if (receiver is DeclarationMirror && tag == 'location') { | |
52 return receiver is! MethodMirror; | |
53 } | |
54 } else if (mirrorSystemType == 'JsMirrorSystem') { | 54 } else if (mirrorSystemType == 'JsMirrorSystem') { |
55 // Dart2js runtime mirror system. | 55 // Dart2js runtime mirror system. |
56 if (receiver is DeclarationMirror && tag == 'location') { | 56 if (receiver is DeclarationMirror && tag == 'location') { |
57 return true; | 57 return true; |
58 } | 58 } |
59 } | 59 } |
60 return false; | 60 return false; |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 void main([List<String> arguments = const <String>[]]) { | 64 void main([List<String> arguments = const <String>[]]) { |
65 MirrorSystem mirrors = currentMirrorSystem(); | 65 MirrorSystem mirrors = currentMirrorSystem(); |
66 MirrorsReader reader = new RuntimeMirrorsReader(mirrors, | 66 MirrorsReader reader = new RuntimeMirrorsReader(mirrors, |
67 verbose: arguments.contains('-v'), | 67 verbose: arguments.contains('-v'), |
68 includeStackTrace: arguments.contains('-s')); | 68 includeStackTrace: arguments.contains('-s')); |
69 reader.checkMirrorSystem(mirrors); | 69 reader.checkMirrorSystem(mirrors); |
70 } | 70 } |
OLD | NEW |