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

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

Issue 10704259: Added getField/setField to ObjectMirror. For InstanceMirrors, this get/sets (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/mirrors_test.dart
===================================================================
--- tests/lib/mirrors/mirrors_test.dart (revision 0)
+++ tests/lib/mirrors/mirrors_test.dart (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (c) 2011, 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.
+
+// TODO(rmacnak): Move the existing mirror tests here (a place for
+// cross-implementation tests).
+
+#library("MirrorsTest.dart");
+#import("dart:mirrors");
+#import("../../../lib/unittest/unittest.dart");
+
+var topLevelField;
+
+class Class {
+ var field;
+ static var staticField;
+}
+
+testFieldAccess(mirrors) {
+ var instance = new Class();
+
+ var libMirror = mirrors.rootLibrary;
+ var classMirror = libMirror.classes()["Class"];
+ var instMirror = mirrors.mirrorOf(instance);
+
+ libMirror.setField('topLevelField', 42);
+ var future = libMirror.getField('topLevelField');
+ future.then(expectAsync1((resultMirror) {
+ expect(resultMirror.reflectee, equals(42));
+ expect(topLevelField, equals(42));
+ }));
+
+ classMirror.setField('staticField', 43);
+ future = classMirror.getField('staticField');
+ future.then(expectAsync1((resultMirror) {
+ expect(resultMirror.reflectee, equals(43));
+ expect(Class.staticField, equals(43));
+ }));
+
+ instMirror.setField('field', 44);
+ future = instMirror.getField('field');
+ future.then(expectAsync1((resultMirror) {
+ expect(resultMirror.reflectee, equals(44));
+ expect(instance.field, equals(44));
+ }));
+}
+
+main() {
+ var mirrors = currentMirrorSystem();
+
+ test("Test field access", () { testFieldAccess(mirrors); });
+}
+
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698