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

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

Issue 26472002: Add TypeVariable object on runtime to support reflection on type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 7 years, 2 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 | « sdk/lib/_internal/lib/js_rti.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/class_mirror_type_variables_test.dart
diff --git a/tests/lib/mirrors/class_mirror_type_variables_test.dart b/tests/lib/mirrors/class_mirror_type_variables_test.dart
index ee7baf95b8def14d0b03a87d9c43dd527904cea4..2a3ea7ef7a47a2d250029d27b0d313f91c3bcfb4 100644
--- a/tests/lib/mirrors/class_mirror_type_variables_test.dart
+++ b/tests/lib/mirrors/class_mirror_type_variables_test.dart
@@ -6,15 +6,44 @@ import "dart:mirrors";
import "package:expect/expect.dart";
+class NoTypeParams {}
+class A<T, S extends String> {}
+class B<Z extends B<Z>> {}
class C<R,S,T> {
R foo(R r) => r;
S bar(S s) => s;
T baz(T t) => t;
}
-class NoTypeParams {}
+testNoTypeParams() {
+ ClassMirror cm = reflectClass(NoTypeParams);
+ Expect.equals(cm.typeVariables.length, 0);
+}
-main() {
+void testA() {
+ ClassMirror a = reflectClass(A);
+ Expect.equals(2, a.typeVariables.length);
+
+ TypeVariableMirror aT = a.typeVariables[0];
+ TypeVariableMirror aS = a.typeVariables[1];
+ TypeMirror aTBound = aT.upperBound.originalDeclaration;
+ TypeMirror aSBound = aS.upperBound.originalDeclaration;
+
+ Expect.equals(reflectClass(Object), aTBound);
+ Expect.equals(reflectClass(String), aSBound);
+}
+
+void testB() {
+ ClassMirror b = reflectClass(B);
+ Expect.equals(1, b.typeVariables.length);
+
+ TypeVariableMirror bZ = b.typeVariables[0];
+ ClassMirror bZBound = bZ.upperBound.originalDeclaration;
+ Expect.equals(b, bZBound);
+ Expect.equals(bZ, bZBound.typeVariables[0]);
+}
+
+testC() {
ClassMirror cm;
cm = reflectClass(C);
Expect.equals(3, cm.typeVariables.length);
@@ -25,6 +54,11 @@ main() {
Expect.equals(#R, values.elementAt(0).simpleName);
Expect.equals(#S, values.elementAt(1).simpleName);
Expect.equals(#T, values.elementAt(2).simpleName);
- cm = reflectClass(NoTypeParams);
- Expect.equals(cm.typeVariables.length, 0);
}
+
+main() {
+ testNoTypeParams();
+ testA();
+ testB();
+ testC();
+}
« no previous file with comments | « sdk/lib/_internal/lib/js_rti.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698