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

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

Issue 29823003: Add test for type variable ownership. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « 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/type_variable_owner_test.dart
diff --git a/tests/lib/mirrors/type_variable_owner_test.dart b/tests/lib/mirrors/type_variable_owner_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c71e39a909377f7e2f0b48928ca84f5e993182bd
--- /dev/null
+++ b/tests/lib/mirrors/type_variable_owner_test.dart
@@ -0,0 +1,32 @@
+// 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.type_variable_owner;
+
+import "dart:mirrors";
+
+import "package:expect/expect.dart";
+
+class A<T> {}
+class B<R> extends A<R> {}
+
+main() {
+ ClassMirror aDecl = reflectClass(A);
+ ClassMirror bDecl = reflectClass(B);
+ ClassMirror aOfInt = reflect(new A<int>()).type;
+ ClassMirror aOfR = bDecl.superclass;
+ ClassMirror bOfString = reflect(new B<String>()).type;
+ ClassMirror aOfString = bOfString.superclass;
+
+ // Owner of a type variable should be the declaration of the generic class,
+ // not an instantiation.
+
+ Expect.equals(aDecl, aDecl.typeVariables[0].owner);
+ Expect.equals(aDecl, aOfInt.typeVariables[0].owner);
+ Expect.equals(aDecl, aOfR.typeVariables[0].owner);
+ Expect.equals(aDecl, aOfString.typeVariables[0].owner);
+
+ Expect.equals(bDecl, bDecl.typeVariables[0].owner);
+ Expect.equals(bDecl, bOfString.typeVariables[0].owner);
+}
« 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