Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: tests/lib/mirrors/mirrors_reader_test.dart

Issue 153553007: Add mirrors_reader_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698