OLD | NEW |
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.generics_substitution; | 5 library test.generics_substitution; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 | 9 |
10 class SuperGeneric<R, S> { | 10 class SuperGeneric<R, S> { |
(...skipping 11 matching lines...) Expand all Loading... |
22 ClassMirror superGenericDecl = reflectClass(SuperGeneric); | 22 ClassMirror superGenericDecl = reflectClass(SuperGeneric); |
23 ClassMirror superOfTAndInt = genericDecl.superclass; | 23 ClassMirror superOfTAndInt = genericDecl.superclass; |
24 ClassMirror superOfStringAndInt = genericOfString.superclass; | 24 ClassMirror superOfStringAndInt = genericOfString.superclass; |
25 | 25 |
26 Expect.isTrue(genericDecl.isOriginalDeclaration); | 26 Expect.isTrue(genericDecl.isOriginalDeclaration); |
27 Expect.isFalse(genericOfString.isOriginalDeclaration); | 27 Expect.isFalse(genericOfString.isOriginalDeclaration); |
28 Expect.isTrue(superGenericDecl.isOriginalDeclaration); | 28 Expect.isTrue(superGenericDecl.isOriginalDeclaration); |
29 Expect.isFalse(superOfTAndInt.isOriginalDeclaration); | 29 Expect.isFalse(superOfTAndInt.isOriginalDeclaration); |
30 Expect.isFalse(superOfStringAndInt.isOriginalDeclaration); | 30 Expect.isFalse(superOfStringAndInt.isOriginalDeclaration); |
31 | 31 |
32 Symbol r(ClassMirror cm) => cm.variables[#r].type.simpleName; | 32 Symbol r(ClassMirror cm) => |
33 Symbol s(ClassMirror cm) => cm.methods[#s].parameters[0].type.simpleName; | 33 (cm.declarations[#r] as VariableMirror).type.simpleName; |
34 Symbol t(ClassMirror cm) => cm.methods[#t].returnType.simpleName; | 34 Symbol s(ClassMirror cm) => |
| 35 (cm.declarations[#s] as MethodMirror).parameters[0].type.simpleName; |
| 36 Symbol t(ClassMirror cm) => |
| 37 (cm.declarations[#t] as MethodMirror).returnType.simpleName; |
35 | 38 |
36 Expect.equals(#T, r(genericDecl.superclass)); /// 01: ok | 39 Expect.equals(#T, r(genericDecl.superclass)); /// 01: ok |
37 Expect.equals(#int, s(genericDecl.superclass)); | 40 Expect.equals(#int, s(genericDecl.superclass)); |
38 Expect.equals(#T, t(genericDecl)); | 41 Expect.equals(#T, t(genericDecl)); |
39 | 42 |
40 Expect.equals(#String, r(genericOfString.superclass)); /// 01: ok | 43 Expect.equals(#String, r(genericOfString.superclass)); /// 01: ok |
41 Expect.equals(#int, s(genericOfString.superclass)); | 44 Expect.equals(#int, s(genericOfString.superclass)); |
42 Expect.equals(#String, t(genericOfString)); | 45 Expect.equals(#String, t(genericOfString)); |
43 | 46 |
44 Expect.equals(#R, r(superGenericDecl)); /// 01: ok | 47 Expect.equals(#R, r(superGenericDecl)); /// 01: ok |
45 Expect.equals(#S, s(superGenericDecl)); | 48 Expect.equals(#S, s(superGenericDecl)); |
46 | 49 |
47 Expect.equals(#T, r(superOfTAndInt)); /// 01: ok | 50 Expect.equals(#T, r(superOfTAndInt)); /// 01: ok |
48 Expect.equals(#int, s(superOfTAndInt)); | 51 Expect.equals(#int, s(superOfTAndInt)); |
49 | 52 |
50 Expect.equals(#String, r(superOfStringAndInt)); /// 01: ok | 53 Expect.equals(#String, r(superOfStringAndInt)); /// 01: ok |
51 Expect.equals(#int, s(superOfStringAndInt)); | 54 Expect.equals(#int, s(superOfStringAndInt)); |
52 } | 55 } |
OLD | NEW |