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

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

Issue 23983026: Fill in type arguments when creating an object from the mirrors or embedding API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: RareType Created 7 years, 3 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
« runtime/vm/object.cc ('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/new_instance_with_type_arguments_test.dart
diff --git a/tests/lib/mirrors/new_instance_with_type_arguments_test.dart b/tests/lib/mirrors/new_instance_with_type_arguments_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..44238ad106a5e9e504ecf3bb30a44dea09ab2e68
--- /dev/null
+++ b/tests/lib/mirrors/new_instance_with_type_arguments_test.dart
@@ -0,0 +1,66 @@
+// Copyright (c) 2013, 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 test.new_instance_with_type_arguments_test;
+
+import 'dart:mirrors';
+
+import 'package:expect/expect.dart';
+
+class A<T> {
+ Type get t => T;
+}
+class B extends A<int> {}
+class C<S> extends A<num> {
+ Type get s => S;
+}
+
+main() {
+ ClassMirror cmA = reflectClass(A);
+ ClassMirror cmB = reflectClass(B);
+ ClassMirror cmC = reflectClass(C);
+
+ var a_int = new A<int>();
+ var a_dynamic = new A();
+ var b = new B();
+ var c_string = new C<String>();
+ var c_dynamic = new C();
+
+ Expect.equals(int, a_int.t);
+ Expect.equals(dynamic, a_dynamic.t);
+ Expect.equals(int, b.t);
+ Expect.equals(num, c_string.t);
+ Expect.equals(num, c_dynamic.t);
+
+ Expect.equals(String, c_string.s);
+ Expect.equals(dynamic, c_dynamic.s);
+
+
+ var reflective_a_int =
+ cmB.superclass.newInstance(const Symbol(''), []).reflectee;
+ var reflective_a_dynamic =
+ cmA.newInstance(const Symbol(''), []).reflectee;
+ var reflective_b =
+ cmB.newInstance(const Symbol(''), []).reflectee;
+ // TODO(rmacnak): Uncomment when reflectType is added to the API.
+ // var reflective_c_string =
+ // reflectType(cmC.runtimeType).newInstance(const Symbol(''), []).reflectee;
+ var reflective_c_dynamic =
+ cmC.newInstance(const Symbol(''), []).reflectee;
+
+ Expect.equals(int, reflective_a_int.t);
+ Expect.equals(dynamic, reflective_a_dynamic.t);
+ Expect.equals(int, reflective_b.t);
+ // Expect.equals(num, c_string.t);
+ Expect.equals(num, reflective_c_dynamic.t);
+
+ // Expect.equals(String, c_string.s);
+ Expect.equals(dynamic, reflective_c_dynamic.s);
+
+ Expect.equals(a_int.runtimeType, reflective_a_int.runtimeType);
+ Expect.equals(a_dynamic.runtimeType, reflective_a_dynamic.runtimeType);
+ Expect.equals(b.runtimeType, reflective_b.runtimeType);
+ // Expect.equals(c_string.runtimeType, reflective_c_string.runtimeType);
+ Expect.equals(c_dynamic.runtimeType, reflective_c_dynamic.runtimeType);
+}
« runtime/vm/object.cc ('K') | « tests/lib/lib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698