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

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

Issue 10834056: Added InterfaceMirror.newInstance(). (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 | « runtime/vm/bootstrap_natives.h ('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 10017)
+++ tests/lib/mirrors/mirrors_test.dart (working copy)
@@ -12,6 +12,8 @@
var topLevelField;
class Class {
+ Class() { this.field = "default value"; }
+ Class.withInitialValue(this.field);
var field;
static var staticField;
}
@@ -61,10 +63,30 @@
}));
}
+testInvokeConstructor(mirrors) {
+ var libMirror = mirrors.libraries()["MirrorsTest.dart"];
+ var classMirror = libMirror.classes()["Class"];
+
+ var future = classMirror.newInstance('', []);
+ future.then(expectAsync1((resultMirror) {
+ var instance = resultMirror.reflectee;
+ expect(instance is Class, equals(true));
+ expect(instance.field, equals("default value"));
+ }));
+
+ future = classMirror.newInstance('withInitialValue', [45]);
+ future.then(expectAsync1((resultMirror) {
+ var instance = resultMirror.reflectee;
+ expect(instance is Class, equals(true));
+ expect(instance.field, equals(45));
+ }));
+}
+
main() {
var mirrors = currentMirrorSystem();
test("Test field access", () { testFieldAccess(mirrors); });
test("Test closure mirrors", () { testClosureMirrors(mirrors); });
+ test("Test invoke constructor", () { testInvokeConstructor(mirrors); });
}
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698