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

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

Issue 39783003: Substitute types in instances of generic classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added regression test and updated dart2js_extra.status. 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/mirrors/class_mirror_type_variables_test.dart ('k') | tests/lib/mirrors/regress_14304_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/mirrors/generic_type_mirror_test.dart
diff --git a/tests/lib/mirrors/generic_type_mirror_test.dart b/tests/lib/mirrors/generic_type_mirror_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6b25a39f21f2bf306a4e99c3808613fb41d06c87
--- /dev/null
+++ b/tests/lib/mirrors/generic_type_mirror_test.dart
@@ -0,0 +1,78 @@
+// 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.
+
+import "dart:mirrors";
+import "package:expect/expect.dart";
+
+class Foo<W, V> {
+ V field;
+ V get bar => field;
+ set bar(V v) {}
+ W m() {}
+ V n() {}
+ o(W w) {}
+}
+
+class Bar {}
+class Baz {}
+
+main() {
+ testInstance();
+ testOriginalDeclaration();
+}
+
+void testInstance() {
+ ClassMirror foo = reflect((new Foo<Bar, Baz>())).type;
+ ClassMirror bar = reflect(new Bar()).type;
+ ClassMirror baz = reflect(new Baz()).type;
+ VariableMirror field = foo.variables.values.single;
+ MethodMirror getter = foo.getters.values.single;
+ MethodMirror setter = foo.setters.values.single;
+ MethodMirror m = foo.methods[const Symbol('m')];
+ MethodMirror n = foo.methods[const Symbol('n')];
+ MethodMirror o = foo.methods[const Symbol('o')];
+
+ Expect.equals(foo, field.owner);
+ Expect.equals(foo, getter.owner);
+ Expect.equals(foo, setter.owner);
+ Expect.equals(foo, m.owner);
+ Expect.equals(foo, n.owner);
+ Expect.equals(foo, o.owner);
+
+ Expect.equals(baz, field.type); /// 01: ok
+ Expect.equals(baz, getter.returnType);
+ Expect.equals(bar, m.returnType);
+ Expect.equals(baz, n.returnType);
+ Expect.equals(bar, o.parameters.single.type);
+ Expect.equals(baz, setter.parameters.single.type);
+
+}
+
+void testOriginalDeclaration() {
+ ClassMirror foo = reflectClass(Foo);
+
+ VariableMirror field = foo.variables.values.single;
+ MethodMirror getter = foo.getters.values.single;
+ MethodMirror setter = foo.setters.values.single;
+ MethodMirror m = foo.methods[const Symbol('m')];
+ MethodMirror n = foo.methods[const Symbol('n')];
+ MethodMirror o = foo.methods[const Symbol('o')];
+ TypeVariableMirror w = foo.typeVariables[0];
+ TypeVariableMirror v = foo.typeVariables[1];
+
+ Expect.equals(foo, field.owner);
+ Expect.equals(foo, getter.owner);
+ Expect.equals(foo, setter.owner);
+ Expect.equals(foo, m.owner);
+ Expect.equals(foo, n.owner);
+ Expect.equals(foo, o.owner);
+
+ Expect.equals(v, field.type); /// 01: ok
+ Expect.equals(v, getter.returnType);
+ Expect.equals(w, m.returnType);
+ Expect.equals(v, n.returnType);
+ Expect.equals(w, o.parameters.single.type);
+ Expect.equals(v, setter.parameters.single.type);
+
+}
« no previous file with comments | « tests/lib/mirrors/class_mirror_type_variables_test.dart ('k') | tests/lib/mirrors/regress_14304_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698