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

Unified Diff: dart/tests/lib/mirrors/reflect_runtime_type_test.dart

Issue 16154021: Implement reflecting on uninstantiated classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update comment in second test. Created 7 years, 6 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: dart/tests/lib/mirrors/reflect_runtime_type_test.dart
diff --git a/dart/tests/lib/mirrors/reflect_runtime_type_test.dart b/dart/tests/lib/mirrors/reflect_runtime_type_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c766c2d2f2a5a17994e4135502f3b29d8ab781fb
--- /dev/null
+++ b/dart/tests/lib/mirrors/reflect_runtime_type_test.dart
@@ -0,0 +1,24 @@
+// Copyright (c) 2013, 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.
+
+// A simple test that ensure that reflection works on runtime types of
+// instantiated classes.
+
+import "dart:mirrors";
+
+class Foo {
+ int a;
+}
+
+main() {
+ var m = reflectClass(new Foo().runtimeType);
+ var field = publicFields(m).single;
+ if (MirrorSystem.getName(field.simpleName) != 'a') {
+ throw 'Expected "a", but got "${MirrorSystem.getName(field.simpleName)}"';
+ }
+ print(field);
+}
+
+Iterable<VariableMirror> publicFields(ClassMirror mirror) =>
+ mirror.variables.values.where((x) => !(x.isPrivate || x.isStatic));

Powered by Google App Engine
This is Rietveld 408576698