| 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 {bool verbose: false, bool includeStackTrace: false}) |
| 17 : this.mirrorSystemType = '${mirrorSystem.runtimeType}', |
| 18 super(verbose: verbose, includeStackTrace: includeStackTrace); |
| 19 |
| 20 bool allowUnsupported(var receiver, String tag, UnsupportedError exception) { |
| 21 if (mirrorSystemType == '_LocalMirrorSystem') { |
| 22 // VM mirror system. |
| 23 } else if (mirrorSystemType == 'JsMirrorSystem') { |
| 24 // Dart2js runtime mirror system. |
| 25 if (tag.endsWith('.metadata')) { |
| 26 return true;// Issue 10905. |
| 27 } |
| 28 } |
| 29 return false; |
| 30 } |
| 31 |
| 32 bool expectUnsupported(var receiver, String tag, UnsupportedError exception) { |
| 33 // [DeclarationMirror.location] is intentionally not supported in runtime |
| 34 // mirrors. |
| 35 if (receiver is DeclarationMirror && tag == 'location') { |
| 36 return true; |
| 37 } |
| 38 if (mirrorSystemType == '_LocalMirrorSystem') { |
| 39 // VM mirror system. |
| 40 } else if (mirrorSystemType == 'JsMirrorSystem') { |
| 41 // Dart2js runtime mirror system. |
| 42 } |
| 43 return false; |
| 44 } |
| 45 } |
| 46 |
| 47 void main(List<String> arguments) { |
| 48 MirrorSystem mirrors = currentMirrorSystem(); |
| 49 MirrorsReader reader = new RuntimeMirrorsReader(mirrors, |
| 50 verbose: arguments.contains('-v'), |
| 51 includeStackTrace: arguments.contains('-s')); |
| 52 reader.checkMirrorSystem(mirrors); |
| 53 } |
| OLD | NEW |