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

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
« tests/lib/lib.status ('K') | « 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,38 @@
+// 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.
+
+#library("MirrorsTest.dart");
+#import("dart:mirrors");
+
+
turnidge 2012/07/17 23:59:33 Add a TODO to move the existing mirrors tests out
+var topLevelField;
+topLevelFunction() {}
+
+class Class {
+ var field;
+ static var staticField;
+}
+
+main() {
+
turnidge 2012/07/17 23:59:33 No blank line here.
+ var instance = new Class();
+
turnidge 2012/07/17 23:59:33 We will eventually have more tests in this file.
+ var mirrors = currentMirrorSystem();
+ var libMirror = mirrors.rootLibrary;
+ var classMirror = libMirror.classes()["Class"];
+ var instMirror = mirrors.mirrorOf(instance);
+
+ libMirror.setField('topLevelField', 42);
+ Expect.equals(42, libMirror.getField('topLevelField').value.reflectee );
turnidge 2012/07/17 23:59:33 It's a little weird for the test to rely on the fu
rmacnak 2012/07/18 00:48:55 But then there should also be some check that the
turnidge 2012/07/18 05:07:35 Yes. I think they have some way of doing this in
rmacnak 2012/07/18 18:04:18 There is no such method on Expect, and I don't see
+ Expect.equals(42, topLevelField );
+
+ classMirror.setField('staticField', 43);
+ Expect.equals(43, classMirror.getField('staticField').value.reflectee );
+ Expect.equals(43, Class.staticField );
+
+ instMirror.setField('field', 44);
+ Expect.equals(44, instMirror.getField('field').value.reflectee );
+ Expect.equals(44, instance.field );
+}
+
« tests/lib/lib.status ('K') | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698