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

Unified 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: Small fix. 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 side-by-side diff with in-line comments
Download patch
Index: tests/lib/mirrors/mirrors_reader_test.dart
diff --git a/tests/lib/mirrors/mirrors_reader_test.dart b/tests/lib/mirrors/mirrors_reader_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..099d043ef6884e1c51ede6a9991190ccf51ce3ea
--- /dev/null
+++ b/tests/lib/mirrors/mirrors_reader_test.dart
@@ -0,0 +1,53 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test that everything reachable from a [MirrorSystem] can be accessed.
+
+library test.mirrors.reader;
+
+import 'dart:mirrors';
+import 'mirrors_reader.dart';
+
+class RuntimeMirrorsReader extends MirrorsReader {
+ final String mirrorSystemType;
+
+ RuntimeMirrorsReader(MirrorSystem mirrorSystem,
+ {bool verbose: false, bool includeStackTrace: false})
+ : this.mirrorSystemType = '${mirrorSystem.runtimeType}',
+ super(verbose: verbose, includeStackTrace: includeStackTrace);
+
+ bool allowUnsupported(var receiver, String tag, UnsupportedError exception) {
+ if (mirrorSystemType == '_LocalMirrorSystem') {
+ // VM mirror system.
+ } else if (mirrorSystemType == 'JsMirrorSystem') {
+ // Dart2js runtime mirror system.
+ if (tag.endsWith('.metadata')) {
+ return true;// Issue 10905.
+ }
+ }
+ return false;
+ }
+
+ bool expectUnsupported(var receiver, String tag, UnsupportedError exception) {
+ // [DeclarationMirror.location] is intentionally not supported in runtime
+ // mirrors.
+ if (receiver is DeclarationMirror && tag == 'location') {
+ return true;
+ }
+ if (mirrorSystemType == '_LocalMirrorSystem') {
+ // VM mirror system.
+ } else if (mirrorSystemType == 'JsMirrorSystem') {
+ // Dart2js runtime mirror system.
+ }
+ return false;
+ }
+}
+
+void main(List<String> arguments) {
+ MirrorSystem mirrors = currentMirrorSystem();
+ MirrorsReader reader = new RuntimeMirrorsReader(mirrors,
+ verbose: arguments.contains('-v'),
+ includeStackTrace: arguments.contains('-s'));
+ reader.checkMirrorSystem(mirrors);
+}

Powered by Google App Engine
This is Rietveld 408576698