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

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

Issue 2774783002: Re-land "Format all multitests" (Closed)
Patch Set: Created 3 years, 9 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
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 import 'generics_helper.dart'; 10 import 'generics_helper.dart';
11 11
12 class A<T> {} 12 class A<T> {}
13
13 class Z<T> {} 14 class Z<T> {}
15
14 class B extends A {} 16 class B extends A {}
17
15 class C 18 class C
16 extends A<num, int> // //# 01: static type warning 19 extends A<num, int> // //# 01: static type warning
17 {} 20 {}
21
18 class D extends A<int> {} 22 class D extends A<int> {}
23
19 class E<S> extends A<S> {} 24 class E<S> extends A<S> {}
25
20 class F<R> extends A<int> {} 26 class F<R> extends A<int> {}
27
21 class G {} 28 class G {}
22 class H<A,B,C> {} 29
30 class H<A, B, C> {}
31
23 class I extends G {} 32 class I extends G {}
24 33
25 main() { 34 main() {
26 // Declarations. 35 // Declarations.
27 typeParameters(reflectClass(A), [#T]); 36 typeParameters(reflectClass(A), [#T]);
28 typeParameters(reflectClass(G), []); 37 typeParameters(reflectClass(G), []);
29 typeParameters(reflectClass(B), []); 38 typeParameters(reflectClass(B), []);
30 typeParameters(reflectClass(C), []); 39 typeParameters(reflectClass(C), []);
31 typeParameters(reflectClass(D), []); 40 typeParameters(reflectClass(D), []);
32 typeParameters(reflectClass(E), [#S]); 41 typeParameters(reflectClass(E), [#S]);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 typeParameters(reflect(new E()).type, [#S]); 82 typeParameters(reflect(new E()).type, [#S]);
74 typeParameters(reflect(new F<num>()).type, [#R]); 83 typeParameters(reflect(new F<num>()).type, [#R]);
75 typeParameters(reflect(new G()).type, []); 84 typeParameters(reflect(new G()).type, []);
76 typeParameters(reflect(new H()).type, [#A, #B, #C]); 85 typeParameters(reflect(new H()).type, [#A, #B, #C]);
77 typeParameters(reflect(new I()).type, []); 86 typeParameters(reflect(new I()).type, []);
78 87
79 var numMirror = reflectClass(num); 88 var numMirror = reflectClass(num);
80 var dynamicMirror = currentMirrorSystem().dynamicType; 89 var dynamicMirror = currentMirrorSystem().dynamicType;
81 typeArguments(reflect(new A<num>()).type, [numMirror]); 90 typeArguments(reflect(new A<num>()).type, [numMirror]);
82 typeArguments(reflect(new A<dynamic>()).type, [dynamicMirror]); 91 typeArguments(reflect(new A<dynamic>()).type, [dynamicMirror]);
83 typeArguments(reflect(new A()).type, [dynamicMirror]); 92 typeArguments(reflect(new A()).type, [dynamicMirror]);
84 typeArguments(reflect(new B()).type, []); 93 typeArguments(reflect(new B()).type, []);
85 typeArguments(reflect(new C()).type, []); 94 typeArguments(reflect(new C()).type, []);
86 typeArguments(reflect(new D()).type, []); 95 typeArguments(reflect(new D()).type, []);
87 typeArguments(reflect(new E<num>()).type, [numMirror]); 96 typeArguments(reflect(new E<num>()).type, [numMirror]);
88 typeArguments(reflect(new E<dynamic>()).type, [dynamicMirror]); 97 typeArguments(reflect(new E<dynamic>()).type, [dynamicMirror]);
89 typeArguments(reflect(new E()).type, [dynamicMirror]); 98 typeArguments(reflect(new E()).type, [dynamicMirror]);
90 typeArguments(reflect(new F<num>()).type, [numMirror]); 99 typeArguments(reflect(new F<num>()).type, [numMirror]);
91 typeArguments(reflect(new F<dynamic>()).type, [dynamicMirror]); 100 typeArguments(reflect(new F<dynamic>()).type, [dynamicMirror]);
92 typeArguments(reflect(new F()).type, [dynamicMirror]); 101 typeArguments(reflect(new F()).type, [dynamicMirror]);
93 typeArguments(reflect(new G()).type, []); 102 typeArguments(reflect(new G()).type, []);
94 typeArguments(reflect(new H<dynamic, num, dynamic>()).type, 103 typeArguments(reflect(new H<dynamic, num, dynamic>()).type,
95 [dynamicMirror, numMirror, dynamicMirror]); 104 [dynamicMirror, numMirror, dynamicMirror]);
96 typeArguments(reflect(new I()).type, []); 105 typeArguments(reflect(new I()).type, []);
97 106
98 Expect.isFalse(reflect(new A<num>()).type.isOriginalDeclaration); 107 Expect.isFalse(reflect(new A<num>()).type.isOriginalDeclaration);
99 Expect.isTrue(reflect(new B()).type.isOriginalDeclaration); 108 Expect.isTrue(reflect(new B()).type.isOriginalDeclaration);
100 Expect.isTrue(reflect(new C()).type.isOriginalDeclaration); 109 Expect.isTrue(reflect(new C()).type.isOriginalDeclaration);
101 Expect.isTrue(reflect(new D()).type.isOriginalDeclaration); 110 Expect.isTrue(reflect(new D()).type.isOriginalDeclaration);
102 Expect.isFalse(reflect(new E<num>()).type.isOriginalDeclaration); 111 Expect.isFalse(reflect(new E<num>()).type.isOriginalDeclaration);
103 Expect.isFalse(reflect(new F<num>()).type.isOriginalDeclaration); 112 Expect.isFalse(reflect(new F<num>()).type.isOriginalDeclaration);
104 Expect.isTrue(reflect(new G()).type.isOriginalDeclaration); 113 Expect.isTrue(reflect(new G()).type.isOriginalDeclaration);
105 Expect.isFalse(reflect(new H()).type.isOriginalDeclaration); 114 Expect.isFalse(reflect(new H()).type.isOriginalDeclaration);
106 Expect.isTrue(reflect(new I()).type.isOriginalDeclaration); 115 Expect.isTrue(reflect(new I()).type.isOriginalDeclaration);
107 116
108 Expect.equals(reflectClass(A), 117 Expect.equals(
109 reflect(new A<num>()).type.originalDeclaration); 118 reflectClass(A), reflect(new A<num>()).type.originalDeclaration);
110 Expect.equals(reflectClass(B), 119 Expect.equals(reflectClass(B), reflect(new B()).type.originalDeclaration);
111 reflect(new B()).type.originalDeclaration); 120 Expect.equals(reflectClass(C), reflect(new C()).type.originalDeclaration);
112 Expect.equals(reflectClass(C), 121 Expect.equals(reflectClass(D), reflect(new D()).type.originalDeclaration);
113 reflect(new C()).type.originalDeclaration); 122 Expect.equals(
114 Expect.equals(reflectClass(D), 123 reflectClass(E), reflect(new E<num>()).type.originalDeclaration);
115 reflect(new D()).type.originalDeclaration); 124 Expect.equals(
116 Expect.equals(reflectClass(E), 125 reflectClass(F), reflect(new F<num>()).type.originalDeclaration);
117 reflect(new E<num>()).type.originalDeclaration); 126 Expect.equals(reflectClass(G), reflect(new G()).type.originalDeclaration);
118 Expect.equals(reflectClass(F), 127 Expect.equals(reflectClass(H), reflect(new H()).type.originalDeclaration);
119 reflect(new F<num>()).type.originalDeclaration); 128 Expect.equals(reflectClass(I), reflect(new I()).type.originalDeclaration);
120 Expect.equals(reflectClass(G),
121 reflect(new G()).type.originalDeclaration);
122 Expect.equals(reflectClass(H),
123 reflect(new H()).type.originalDeclaration);
124 Expect.equals(reflectClass(I),
125 reflect(new I()).type.originalDeclaration);
126 129
127 Expect.notEquals(reflect(new A<num>()).type, 130 Expect.notEquals(reflect(new A<num>()).type,
128 reflect(new A<num>()).type.originalDeclaration); 131 reflect(new A<num>()).type.originalDeclaration);
129 Expect.equals(reflect(new B()).type, 132 Expect.equals(
130 reflect(new B()).type.originalDeclaration); 133 reflect(new B()).type, reflect(new B()).type.originalDeclaration);
131 Expect.equals(reflect(new C()).type, 134 Expect.equals(
132 reflect(new C()).type.originalDeclaration); 135 reflect(new C()).type, reflect(new C()).type.originalDeclaration);
133 Expect.equals(reflect(new D()).type, 136 Expect.equals(
134 reflect(new D()).type.originalDeclaration); 137 reflect(new D()).type, reflect(new D()).type.originalDeclaration);
135 Expect.notEquals(reflect(new E<num>()).type, 138 Expect.notEquals(reflect(new E<num>()).type,
136 reflect(new E<num>()).type.originalDeclaration); 139 reflect(new E<num>()).type.originalDeclaration);
137 Expect.notEquals(reflect(new F<num>()).type, 140 Expect.notEquals(reflect(new F<num>()).type,
138 reflect(new F<num>()).type.originalDeclaration); 141 reflect(new F<num>()).type.originalDeclaration);
139 Expect.equals(reflect(new G()).type, 142 Expect.equals(
140 reflect(new G()).type.originalDeclaration); 143 reflect(new G()).type, reflect(new G()).type.originalDeclaration);
141 Expect.notEquals(reflect(new H()).type, 144 Expect.notEquals(
142 reflect(new H()).type.originalDeclaration); 145 reflect(new H()).type, reflect(new H()).type.originalDeclaration);
143 Expect.equals(reflect(new I()).type, 146 Expect.equals(
144 reflect(new I()).type.originalDeclaration); 147 reflect(new I()).type, reflect(new I()).type.originalDeclaration);
145 148
146 // Library members are all uninstantaited generics or non-generics. 149 // Library members are all uninstantaited generics or non-generics.
147 currentMirrorSystem().libraries.values.forEach((libraryMirror) { 150 currentMirrorSystem().libraries.values.forEach((libraryMirror) {
148 libraryMirror.declarations.values.forEach((declaration) { 151 libraryMirror.declarations.values.forEach((declaration) {
149 if (declaration is ClassMirror) { 152 if (declaration is ClassMirror) {
150 Expect.isTrue(declaration.isOriginalDeclaration); 153 Expect.isTrue(declaration.isOriginalDeclaration);
151 Expect.equals(declaration, declaration.originalDeclaration); 154 Expect.equals(declaration, declaration.originalDeclaration);
152 } 155 }
153 }); 156 });
154 }); 157 });
155 158
156 Expect.equals(reflectClass(A).typeVariables[0].owner, reflectClass(A)); 159 Expect.equals(reflectClass(A).typeVariables[0].owner, reflectClass(A));
157 Expect.equals(reflectClass(Z).typeVariables[0].owner, reflectClass(Z)); 160 Expect.equals(reflectClass(Z).typeVariables[0].owner, reflectClass(Z));
158 Expect.notEquals(reflectClass(A).typeVariables[0], 161 Expect.notEquals(
159 reflectClass(Z).typeVariables[0]); 162 reflectClass(A).typeVariables[0], reflectClass(Z).typeVariables[0]);
160 Expect.equals(reflectClass(A).typeVariables[0], 163 Expect.equals(
161 reflectClass(A).typeVariables[0]); 164 reflectClass(A).typeVariables[0], reflectClass(A).typeVariables[0]);
162 } 165 }
OLDNEW
« no previous file with comments | « tests/lib/mirrors/generics_double_substitution_test.dart ('k') | tests/lib/mirrors/globalized_closures2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698