| 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 // Test that everything reachable from a [MirrorSystem] can be accessed. |
| 6 |
| 7 library test.mirrors.reader; |
| 8 |
| 9 import 'dart:mirrors'; |
| 10 import 'mirrors_reader.dart'; |
| 11 |
| 12 class RuntimeMirrorsReader extends MirrorsReader { |
| 13 final String mirrorSystemType; |
| 14 |
| 15 RuntimeMirrorsReader(MirrorSystem mirrorSystem) |
| 16 : this.mirrorSystemType = '${mirrorSystem.runtimeType}'; |
| 17 |
| 18 bool allowUnsupported(var receiver, String tag, UnsupportedError exception) { |
| 19 if (mirrorSystemType == '_LocalMirrorSystem') { |
| 20 // VM mirror system. |
| 21 } else if (mirrorSystemType == 'JsMirrorSystem') { |
| 22 // Dart2js runtime mirror system. |
| 23 if (tag.endsWith('.metadata')) { |
| 24 return true;// Issue 10905. |
| 25 } |
| 26 } |
| 27 return false; |
| 28 } |
| 29 |
| 30 bool expectUnsupported(var receiver, String tag, UnsupportedError exception) { |
| 31 // [DeclarationMirror.location] is intentionally not supported in runtime |
| 32 // mirrors. |
| 33 if (receiver is DeclarationMirror && tag == 'location') { |
| 34 return true; |
| 35 } |
| 36 if (mirrorSystemType == '_LocalMirrorSystem') { |
| 37 // VM mirror system. |
| 38 } else if (mirrorSystemType == 'JsMirrorSystem') { |
| 39 // Dart2js runtime mirror system. |
| 40 } |
| 41 return false; |
| 42 } |
| 43 } |
| 44 |
| 45 void main() { |
| 46 MirrorSystem mirrors = currentMirrorSystem(); |
| 47 MirrorsReader reader = new RuntimeMirrorsReader(mirrors); |
| 48 readMirrorSystem(reader, mirrors); |
| 49 } |
| OLD | NEW |