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

Side by Side Diff: tests/lib/mirrors/mirrors_test.dart

Issue 10800065: Added ClosureMirror to dart:mirrors. Added Dart_ClosureFunction to the (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('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
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // TODO(rmacnak): Move the existing mirror tests here (a place for 5 // TODO(rmacnak): Move the existing mirror tests here (a place for
6 // cross-implementation tests). 6 // cross-implementation tests).
7 7
8 #library("MirrorsTest.dart"); 8 #library("MirrorsTest.dart");
9 #import("dart:mirrors"); 9 #import("dart:mirrors");
10 #import("../../../lib/unittest/unittest.dart"); 10 #import("../../../lib/unittest/unittest.dart");
(...skipping 27 matching lines...) Expand all
38 })); 38 }));
39 39
40 instMirror.setField('field', 44); 40 instMirror.setField('field', 44);
41 future = instMirror.getField('field'); 41 future = instMirror.getField('field');
42 future.then(expectAsync1((resultMirror) { 42 future.then(expectAsync1((resultMirror) {
43 expect(resultMirror.reflectee, equals(44)); 43 expect(resultMirror.reflectee, equals(44));
44 expect(instance.field, equals(44)); 44 expect(instance.field, equals(44));
45 })); 45 }));
46 } 46 }
47 47
48 testClosureMirrors(mirrors) {
49 var closure = (x, y, z) { return x + y + z; };
50
51 var mirror = mirrors.mirrorOf(closure);
52 expect(mirror is ClosureMirror, equals(true));
53
54 var funcMirror = mirror.function();
55 expect(funcMirror is MethodMirror, equals(true));
56 expect(funcMirror.parameters().length, equals(3));
57
58 var future = mirror.apply([2, 4, 8]);
59 future.then(expectAsync1((resultMirror) {
60 expect(resultMirror.reflectee, equals(14));
61 }));
62 }
63
48 main() { 64 main() {
49 var mirrors = currentMirrorSystem(); 65 var mirrors = currentMirrorSystem();
50 66
51 test("Test field access", () { testFieldAccess(mirrors); }); 67 test("Test field access", () { testFieldAccess(mirrors); });
68 test("Test closure mirrors", () { testClosureMirrors(mirrors); });
52 } 69 }
53 70
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698