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

Side by Side Diff: tests/lib/mirrors/generics_test.dart

Issue 23890036: Change return type of get typeVariables and typeArguments in ClassMirror. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.type_arguments_test; 5 library test.type_arguments_test;
6 6
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 8
9 import 'package:expect/expect.dart'; 9 import 'package:expect/expect.dart';
10 10
11 class A<T> {} 11 class A<T> {}
12 class B extends A {} // Same as class B extends A<dynamic>. 12 class B extends A {} // Same as class B extends A<dynamic>.
13 class C extends A<num, int> {} // Same as class C extends A<dynamic>. 13 class C extends A<num, int> {} // Same as class C extends A<dynamic>.
14 class D extends A<int> {} 14 class D extends A<int> {}
15 class E<S> extends A<S> {} 15 class E<S> extends A<S> {}
16 class F<R> extends A<int> {} 16 class F<R> extends A<int> {}
17 class G {} 17 class G {}
18 class H<A,B,C> {} 18 class H<A,B,C> {}
19 19
20 typeParameters(mirror, parameterNames) { 20 typeParameters(mirror, parameterNames) {
21 Expect.listEquals(parameterNames.map((n) => new Symbol(n)).toList(), 21 Expect.listEquals(parameterNames.map((n) => new Symbol(n)).toList(),
22 mirror.typeVariables.keys.toList()); 22 mirror.typeVariables.map((v) => v.simpleName).toList());
23 } 23 }
24 24
25 typeArguments(mirror, argumentMirrors) { 25 typeArguments(mirror, argumentMirrors) {
26 Expect.listEquals(argumentMirrors, 26 Expect.listEquals(argumentMirrors,
27 mirror.typeArguments.values.toList()); 27 mirror.typeArguments);
28 if (!mirror.isOriginalDeclaration) {
29 Expect.listEquals(mirror.typeVariables.keys.toList(),
30 mirror.typeArguments.keys.toList());
31 }
32 } 28 }
33 29
34 main() { 30 main() {
35 // Declarations. 31 // Declarations.
36 typeParameters(reflectClass(A), ['T']); 32 typeParameters(reflectClass(A), ['T']);
37 typeParameters(reflectClass(B), []); 33 typeParameters(reflectClass(B), []);
38 typeParameters(reflectClass(C), []); 34 typeParameters(reflectClass(C), []);
39 typeParameters(reflectClass(D), []); 35 typeParameters(reflectClass(D), []);
40 typeParameters(reflectClass(E), ['S']); 36 typeParameters(reflectClass(E), ['S']);
41 typeParameters(reflectClass(F), ['R']); 37 typeParameters(reflectClass(F), ['R']);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 currentMirrorSystem().libraries.values.forEach((libraryMirror) { 136 currentMirrorSystem().libraries.values.forEach((libraryMirror) {
141 libraryMirror.classes.values.forEach((classMirror) { 137 libraryMirror.classes.values.forEach((classMirror) {
142 // TODO(12282): Deal with generic typedefs. 138 // TODO(12282): Deal with generic typedefs.
143 if (classMirror is! TypedefMirror) { 139 if (classMirror is! TypedefMirror) {
144 Expect.isTrue(classMirror.isOriginalDeclaration); 140 Expect.isTrue(classMirror.isOriginalDeclaration);
145 Expect.equals(classMirror, classMirror.originalDeclaration); 141 Expect.equals(classMirror, classMirror.originalDeclaration);
146 } 142 }
147 }); 143 });
148 }); 144 });
149 } 145 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/class_mirror_type_variables_test.dart ('k') | tests/lib/mirrors/mirrors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698