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

Side by Side 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, 4 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
« no previous file with comments | « tests/lib/lib.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, 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 // TODO(rmacnak): Move the existing mirror tests here (a place for
6 // cross-implementation tests).
7
8 #library("MirrorsTest.dart");
9 #import("dart:mirrors");
10 #import("../../../lib/unittest/unittest.dart");
11
12 var topLevelField;
13
14 class Class {
15 var field;
16 static var staticField;
17 }
18
19 testFieldAccess(mirrors) {
20 var instance = new Class();
21
22 var libMirror = mirrors.rootLibrary;
23 var classMirror = libMirror.classes()["Class"];
24 var instMirror = mirrors.mirrorOf(instance);
25
26 libMirror.setField('topLevelField', 42);
27 var future = libMirror.getField('topLevelField');
28 future.then(expectAsync1((resultMirror) {
29 expect(resultMirror.reflectee, equals(42));
30 expect(topLevelField, equals(42));
31 }));
32
33 classMirror.setField('staticField', 43);
34 future = classMirror.getField('staticField');
35 future.then(expectAsync1((resultMirror) {
36 expect(resultMirror.reflectee, equals(43));
37 expect(Class.staticField, equals(43));
38 }));
39
40 instMirror.setField('field', 44);
41 future = instMirror.getField('field');
42 future.then(expectAsync1((resultMirror) {
43 expect(resultMirror.reflectee, equals(44));
44 expect(instance.field, equals(44));
45 }));
46 }
47
48 main() {
49 var mirrors = currentMirrorSystem();
50
51 test("Test field access", () { testFieldAccess(mirrors); });
52 }
53
OLDNEW
« 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