| 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.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 import 'generics_helper.dart'; | 10 import 'generics_helper.dart'; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 typeParameters(reflect(new E()).type, [#S]); | 73 typeParameters(reflect(new E()).type, [#S]); |
| 74 typeParameters(reflect(new F<num>()).type, [#R]); | 74 typeParameters(reflect(new F<num>()).type, [#R]); |
| 75 typeParameters(reflect(new G()).type, []); | 75 typeParameters(reflect(new G()).type, []); |
| 76 typeParameters(reflect(new H()).type, [#A, #B, #C]); | 76 typeParameters(reflect(new H()).type, [#A, #B, #C]); |
| 77 typeParameters(reflect(new I()).type, []); | 77 typeParameters(reflect(new I()).type, []); |
| 78 | 78 |
| 79 var numMirror = reflectClass(num); | 79 var numMirror = reflectClass(num); |
| 80 var dynamicMirror = currentMirrorSystem().dynamicType; | 80 var dynamicMirror = currentMirrorSystem().dynamicType; |
| 81 typeArguments(reflect(new A<num>()).type, [numMirror]); | 81 typeArguments(reflect(new A<num>()).type, [numMirror]); |
| 82 typeArguments(reflect(new A<dynamic>()).type, [dynamicMirror]); | 82 typeArguments(reflect(new A<dynamic>()).type, [dynamicMirror]); |
| 83 typeArguments(reflect(new A()).type, [dynamicMirror]); /// 01: ok | 83 typeArguments(reflect(new A()).type, [dynamicMirror]); |
| 84 typeArguments(reflect(new B()).type, []); | 84 typeArguments(reflect(new B()).type, []); |
| 85 typeArguments(reflect(new C()).type, []); | 85 typeArguments(reflect(new C()).type, []); |
| 86 typeArguments(reflect(new D()).type, []); | 86 typeArguments(reflect(new D()).type, []); |
| 87 typeArguments(reflect(new E<num>()).type, [numMirror]); | 87 typeArguments(reflect(new E<num>()).type, [numMirror]); |
| 88 typeArguments(reflect(new E<dynamic>()).type, [dynamicMirror]); /// 01: ok | 88 typeArguments(reflect(new E<dynamic>()).type, [dynamicMirror]); |
| 89 typeArguments(reflect(new E()).type, [dynamicMirror]); /// 01: ok | 89 typeArguments(reflect(new E()).type, [dynamicMirror]); |
| 90 typeArguments(reflect(new F<num>()).type, [numMirror]); | 90 typeArguments(reflect(new F<num>()).type, [numMirror]); |
| 91 typeArguments(reflect(new F<dynamic>()).type, [dynamicMirror]); /// 01: ok | 91 typeArguments(reflect(new F<dynamic>()).type, [dynamicMirror]); |
| 92 typeArguments(reflect(new F()).type, [dynamicMirror]); /// 01: ok | 92 typeArguments(reflect(new F()).type, [dynamicMirror]); |
| 93 typeArguments(reflect(new G()).type, []); | 93 typeArguments(reflect(new G()).type, []); |
| 94 typeArguments(reflect(new H<dynamic, num, dynamic>()).type, /// 01: ok | 94 typeArguments(reflect(new H<dynamic, num, dynamic>()).type, |
| 95 [dynamicMirror, numMirror, dynamicMirror]); /// 01: ok | 95 [dynamicMirror, numMirror, dynamicMirror]); |
| 96 typeArguments(reflect(new I()).type, []); | 96 typeArguments(reflect(new I()).type, []); |
| 97 | 97 |
| 98 Expect.isFalse(reflect(new A<num>()).type.isOriginalDeclaration); | 98 Expect.isFalse(reflect(new A<num>()).type.isOriginalDeclaration); |
| 99 Expect.isTrue(reflect(new B()).type.isOriginalDeclaration); | 99 Expect.isTrue(reflect(new B()).type.isOriginalDeclaration); |
| 100 Expect.isTrue(reflect(new C()).type.isOriginalDeclaration); | 100 Expect.isTrue(reflect(new C()).type.isOriginalDeclaration); |
| 101 Expect.isTrue(reflect(new D()).type.isOriginalDeclaration); | 101 Expect.isTrue(reflect(new D()).type.isOriginalDeclaration); |
| 102 Expect.isFalse(reflect(new E<num>()).type.isOriginalDeclaration); | 102 Expect.isFalse(reflect(new E<num>()).type.isOriginalDeclaration); |
| 103 Expect.isFalse(reflect(new F<num>()).type.isOriginalDeclaration); | 103 Expect.isFalse(reflect(new F<num>()).type.isOriginalDeclaration); |
| 104 Expect.isTrue(reflect(new G()).type.isOriginalDeclaration); | 104 Expect.isTrue(reflect(new G()).type.isOriginalDeclaration); |
| 105 Expect.isFalse(reflect(new H()).type.isOriginalDeclaration); /// 01: ok | 105 Expect.isFalse(reflect(new H()).type.isOriginalDeclaration); |
| 106 Expect.isTrue(reflect(new I()).type.isOriginalDeclaration); | 106 Expect.isTrue(reflect(new I()).type.isOriginalDeclaration); |
| 107 | 107 |
| 108 Expect.equals(reflectClass(A), | 108 Expect.equals(reflectClass(A), |
| 109 reflect(new A<num>()).type.originalDeclaration); | 109 reflect(new A<num>()).type.originalDeclaration); |
| 110 Expect.equals(reflectClass(B), | 110 Expect.equals(reflectClass(B), |
| 111 reflect(new B()).type.originalDeclaration); | 111 reflect(new B()).type.originalDeclaration); |
| 112 Expect.equals(reflectClass(C), | 112 Expect.equals(reflectClass(C), |
| 113 reflect(new C()).type.originalDeclaration); | 113 reflect(new C()).type.originalDeclaration); |
| 114 Expect.equals(reflectClass(D), | 114 Expect.equals(reflectClass(D), |
| 115 reflect(new D()).type.originalDeclaration); | 115 reflect(new D()).type.originalDeclaration); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 131 Expect.equals(reflect(new C()).type, | 131 Expect.equals(reflect(new C()).type, |
| 132 reflect(new C()).type.originalDeclaration); | 132 reflect(new C()).type.originalDeclaration); |
| 133 Expect.equals(reflect(new D()).type, | 133 Expect.equals(reflect(new D()).type, |
| 134 reflect(new D()).type.originalDeclaration); | 134 reflect(new D()).type.originalDeclaration); |
| 135 Expect.notEquals(reflect(new E<num>()).type, | 135 Expect.notEquals(reflect(new E<num>()).type, |
| 136 reflect(new E<num>()).type.originalDeclaration); | 136 reflect(new E<num>()).type.originalDeclaration); |
| 137 Expect.notEquals(reflect(new F<num>()).type, | 137 Expect.notEquals(reflect(new F<num>()).type, |
| 138 reflect(new F<num>()).type.originalDeclaration); | 138 reflect(new F<num>()).type.originalDeclaration); |
| 139 Expect.equals(reflect(new G()).type, | 139 Expect.equals(reflect(new G()).type, |
| 140 reflect(new G()).type.originalDeclaration); | 140 reflect(new G()).type.originalDeclaration); |
| 141 Expect.notEquals(reflect(new H()).type, /// 01: ok | 141 Expect.notEquals(reflect(new H()).type, |
| 142 reflect(new H()).type.originalDeclaration); /// 01: ok | 142 reflect(new H()).type.originalDeclaration); |
| 143 Expect.equals(reflect(new I()).type, | 143 Expect.equals(reflect(new I()).type, |
| 144 reflect(new I()).type.originalDeclaration); | 144 reflect(new I()).type.originalDeclaration); |
| 145 | 145 |
| 146 // Library members are all uninstantaited generics or non-generics. | 146 // Library members are all uninstantaited generics or non-generics. |
| 147 currentMirrorSystem().libraries.values.forEach((libraryMirror) { | 147 currentMirrorSystem().libraries.values.forEach((libraryMirror) { |
| 148 libraryMirror.declarations.values.forEach((declaration) { | 148 libraryMirror.declarations.values.forEach((declaration) { |
| 149 if (declaration is ClassMirror) { | 149 if (declaration is ClassMirror) { |
| 150 Expect.isTrue(declaration.isOriginalDeclaration); | 150 Expect.isTrue(declaration.isOriginalDeclaration); |
| 151 Expect.equals(declaration, declaration.originalDeclaration); | 151 Expect.equals(declaration, declaration.originalDeclaration); |
| 152 } | 152 } |
| 153 }); | 153 }); |
| 154 }); | 154 }); |
| 155 | 155 |
| 156 Expect.equals(reflectClass(A).typeVariables[0].owner, reflectClass(A)); | 156 Expect.equals(reflectClass(A).typeVariables[0].owner, reflectClass(A)); |
| 157 Expect.equals(reflectClass(Z).typeVariables[0].owner, reflectClass(Z)); | 157 Expect.equals(reflectClass(Z).typeVariables[0].owner, reflectClass(Z)); |
| 158 Expect.notEquals(reflectClass(A).typeVariables[0], | 158 Expect.notEquals(reflectClass(A).typeVariables[0], |
| 159 reflectClass(Z).typeVariables[0]); | 159 reflectClass(Z).typeVariables[0]); |
| 160 Expect.equals(reflectClass(A).typeVariables[0], | 160 Expect.equals(reflectClass(A).typeVariables[0], |
| 161 reflectClass(A).typeVariables[0]); | 161 reflectClass(A).typeVariables[0]); |
| 162 } | 162 } |
| OLD | NEW |