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

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

Issue 23180004: Change simpleName of anonymous mixin applications. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged and removed TODO. 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
« no previous file with comments | « dart/tests/lib/mirrors/hierarchy_test.dart ('k') | dart/tests/lib/mirrors/mixin_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // TODO(ahe): This test is sligthly broken but provides temporary test coverage
6 // for dart2js. See http://dartbug.com/12464.
7
8 library test.mixin_test;
9
10 @MirrorsUsed(targets: 'test.mixin_test, test.model, Object', override: '*')
11 import 'dart:mirrors';
12
13 import 'package:expect/expect.dart';
14
15 import 'model.dart';
16 import 'stringify.dart';
17
18 class Mixin {
19 int i;
20 m() {}
21 }
22
23 class Mixin2 {
24 int i2;
25 m2() {}
26 }
27
28 typedef MixinApplication = C with Mixin;
29 typedef MixinApplicationA = C with Mixin, Mixin2;
30
31 typedef UnusedMixinApplication = C with Mixin;
32
33 class Subclass extends C with Mixin {
34 f() {}
35 }
36
37 class Subclass2 extends MixinApplication {
38 g() {}
39 }
40
41 class SubclassA extends C with Mixin, Mixin2 {
42 fa() {}
43 }
44
45 class Subclass2A extends MixinApplicationA {
46 ga() {}
47 }
48
49 checkClass(Type type, List<String> expectedSuperclasses) {
50 int i = 0;
51 for (var cls = reflectClass(type); cls != null; cls = cls.superclass) {
52 expect(expectedSuperclasses[i++], cls);
53 }
54 Expect.equals(i, expectedSuperclasses.length, '$type');
55 }
56
57 expectSame(ClassMirror a, ClassMirror b) {
58 Expect.equals(a, b);
59 expect(stringify(a), b);
60 expect(stringify(b), a);
61 }
62
63 testMixin() {
64 checkClass(Mixin, [
65 'Class(s(Mixin) in s(test.mixin_test), top-level)',
66 'Class(s(Object) in s(dart.core), top-level)',
67 ]);
68
69 expect(
70 '{i: Variable(s(i) in s(Mixin)),'
71 ' m: Method(s(m) in s(Mixin))}',
72 reflectClass(Mixin).members);
73
74 expect('{Mixin: Method(s(Mixin) in s(Mixin), constructor)}',
75 reflectClass(Mixin).constructors);
76 }
77
78 testMixin2() {
79 checkClass(Mixin2, [
80 'Class(s(Mixin2) in s(test.mixin_test), top-level)',
81 'Class(s(Object) in s(dart.core), top-level)',
82 ]);
83
84 expect(
85 '{i2: Variable(s(i2) in s(Mixin2)),'
86 ' m2: Method(s(m2) in s(Mixin2))}',
87 reflectClass(Mixin2).members);
88
89 expect('{Mixin2: Method(s(Mixin2) in s(Mixin2), constructor)}',
90 reflectClass(Mixin2).constructors);
91 }
92
93 testMixinApplication() {
94 checkClass(MixinApplication, [
95 'Class(s(MixinApplication) in s(test.mixin_test), top-level)',
96 'Class(s(C) in s(test.model), top-level)',
97 'Class(s(B) in s(test.model), top-level)',
98 'Class(s(A) in s(test.model), top-level)',
99 'Class(s(Object) in s(dart.core), top-level)',
100 ]);
101
102 expect(
103 '{i: Variable(s(i) in s(MixinApplication)),'
104 ' m: Method(s(m) in s(MixinApplication))}',
105 reflectClass(MixinApplication).members);
106
107 expect('{MixinApplication: Method(s(MixinApplication) in s(MixinApplication),'
108 ' constructor)}',
109 reflectClass(MixinApplication).constructors);
110
111 expectSame(reflectClass(C), reflectClass(MixinApplication).superclass);
112 }
113
114 testMixinApplicationA() {
115 checkClass(MixinApplicationA, [
116 'Class(s(MixinApplicationA) in s(test.mixin_test), top-level)',
117 'Class(s(test.mixin_test.Mixin(test.model.C)), top-level)',
118 'Class(s(C) in s(test.model), top-level)',
119 'Class(s(B) in s(test.model), top-level)',
120 'Class(s(A) in s(test.model), top-level)',
121 'Class(s(Object) in s(dart.core), top-level)',
122 ]);
123
124 expect(
125 // TODO(ahe): The owner should be the mixin.
126 '{i2: Variable(s(i2) in s(MixinApplicationA)),'
127 ' m2: Method(s(m2) in s(MixinApplicationA))}',
128 reflectClass(MixinApplicationA).members);
129
130 expect(
131 '{MixinApplicationA: Method(s(MixinApplicationA) in s(MixinApplicationA),'
132 ' constructor)}',
133 reflectClass(MixinApplicationA).constructors);
134
135 expect(
136 '{i: Variable(s(i) in s(Mixin)),'
137 ' m: Method(s(m) in s(Mixin))}',
138 reflectClass(MixinApplicationA).superclass.members);
139
140 expect(
141 // TODO(ahe): The owner should be the mixin application.
142 '{Mixin: Method(s(Mixin) in s(Mixin), constructor)}',
143 reflectClass(MixinApplicationA).superclass.constructors);
144
145 expectSame(
146 reflectClass(C),
147 reflectClass(MixinApplicationA).superclass.superclass);
148 }
149
150 testUnusedMixinApplication() {
151 checkClass(UnusedMixinApplication, [
152 'Class(s(UnusedMixinApplication) in s(test.mixin_test), top-level)',
153 'Class(s(C) in s(test.model), top-level)',
154 'Class(s(B) in s(test.model), top-level)',
155 'Class(s(A) in s(test.model), top-level)',
156 'Class(s(Object) in s(dart.core), top-level)',
157 ]);
158
159 expect(
160 '{i: Variable(s(i) in s(UnusedMixinApplication)),'
161 ' m: Method(s(m) in s(UnusedMixinApplication))}',
162 reflectClass(UnusedMixinApplication).members);
163
164 expect(
165 '{UnusedMixinApplication: Method(s(UnusedMixinApplication)'
166 ' in s(UnusedMixinApplication), constructor)}',
167 reflectClass(UnusedMixinApplication).constructors);
168
169 expectSame(reflectClass(C), reflectClass(UnusedMixinApplication).superclass);
170 }
171
172 testSubclass() {
173 checkClass(Subclass, [
174 'Class(s(Subclass) in s(test.mixin_test), top-level)',
175 'Class(s(test.mixin_test.Mixin(test.model.C)), top-level)',
176 'Class(s(C) in s(test.model), top-level)',
177 'Class(s(B) in s(test.model), top-level)',
178 'Class(s(A) in s(test.model), top-level)',
179 'Class(s(Object) in s(dart.core), top-level)',
180 ]);
181
182 expect(
183 '{f: Method(s(f) in s(Subclass))}',
184 reflectClass(Subclass).members);
185
186 expect(
187 '{Subclass: Method(s(Subclass) in s(Subclass), constructor)}',
188 reflectClass(Subclass).constructors);
189
190 expect(
191 '{i: Variable(s(i) in s(Mixin)),'
192 ' m: Method(s(m) in s(Mixin))}',
193 reflectClass(Subclass).superclass.members);
194
195 expect(
196 // TODO(ahe): The owner should be the mixin application.
197 '{Mixin: Method(s(Mixin) in s(Mixin), constructor)}',
198 reflectClass(Subclass).superclass.constructors);
199
200 expectSame(
201 reflectClass(C),
202 reflectClass(Subclass).superclass.superclass);
203 }
204
205 testSubclass2() {
206 checkClass(Subclass2, [
207 'Class(s(Subclass2) in s(test.mixin_test), top-level)',
208 'Class(s(MixinApplication) in s(test.mixin_test), top-level)',
209 'Class(s(C) in s(test.model), top-level)',
210 'Class(s(B) in s(test.model), top-level)',
211 'Class(s(A) in s(test.model), top-level)',
212 'Class(s(Object) in s(dart.core), top-level)',
213 ]);
214
215 expect(
216 '{g: Method(s(g) in s(Subclass2))}',
217 reflectClass(Subclass2).members);
218
219 expect(
220 '{Subclass2: Method(s(Subclass2) in s(Subclass2), constructor)}',
221 reflectClass(Subclass2).constructors);
222
223 expectSame(
224 reflectClass(MixinApplication),
225 reflectClass(Subclass2).superclass);
226 }
227
228 testSubclassA() {
229 checkClass(SubclassA, [
230 'Class(s(SubclassA) in s(test.mixin_test), top-level)',
231 'Class(s(test.mixin_test.Mixin2(test.mixin_test.Mixin(test.model.C))),'
232 ' top-level)',
233 'Class(s(test.mixin_test.Mixin(test.model.C)), top-level)',
234 'Class(s(C) in s(test.model), top-level)',
235 'Class(s(B) in s(test.model), top-level)',
236 'Class(s(A) in s(test.model), top-level)',
237 'Class(s(Object) in s(dart.core), top-level)',
238 ]);
239
240 expect(
241 '{fa: Method(s(fa) in s(SubclassA))}',
242 reflectClass(SubclassA).members);
243
244 expect(
245 '{SubclassA: Method(s(SubclassA) in s(SubclassA), constructor)}',
246 reflectClass(SubclassA).constructors);
247
248 expect(
249 '{i2: Variable(s(i2) in s(Mixin2)),'
250 ' m2: Method(s(m2) in s(Mixin2))}',
251 reflectClass(SubclassA).superclass.members);
252
253 expect(
254 // TODO(ahe): The owner should be the mixin application.
255 '{Mixin2: Method(s(Mixin2) in s(Mixin2), constructor)}',
256 reflectClass(SubclassA).superclass.constructors);
257
258 expect(
259 '{i: Variable(s(i) in s(Mixin)),'
260 ' m: Method(s(m) in s(Mixin))}',
261 reflectClass(SubclassA).superclass.superclass.members);
262
263 expect(
264 // TODO(ahe): The owner should be the mixin application.
265 '{Mixin: Method(s(Mixin) in s(Mixin), constructor)}',
266 reflectClass(SubclassA).superclass.superclass.constructors);
267
268 expectSame(
269 reflectClass(C),
270 reflectClass(SubclassA).superclass.superclass.superclass);
271 }
272
273 testSubclass2A() {
274 checkClass(Subclass2A, [
275 'Class(s(Subclass2A) in s(test.mixin_test), top-level)',
276 'Class(s(MixinApplicationA) in s(test.mixin_test), top-level)',
277 'Class(s(test.mixin_test.Mixin(test.model.C)), top-level)',
278 'Class(s(C) in s(test.model), top-level)',
279 'Class(s(B) in s(test.model), top-level)',
280 'Class(s(A) in s(test.model), top-level)',
281 'Class(s(Object) in s(dart.core), top-level)',
282 ]);
283
284 expect(
285 '{ga: Method(s(ga) in s(Subclass2A))}',
286 reflectClass(Subclass2A).members);
287
288 expect(
289 '{Subclass2A: Method(s(Subclass2A) in s(Subclass2A), constructor)}',
290 reflectClass(Subclass2A).constructors);
291
292 expectSame(reflectClass(MixinApplicationA),
293 reflectClass(Subclass2A).superclass);
294 }
295
296 main() {
297 testMixin();
298 testMixin2();
299 testMixinApplication();
300 testMixinApplicationA();
301 testUnusedMixinApplication();
302 testSubclass();
303 testSubclass2();
304 testSubclassA();
305 testSubclass2A();
306 }
OLDNEW
« no previous file with comments | « dart/tests/lib/mirrors/hierarchy_test.dart ('k') | dart/tests/lib/mirrors/mixin_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698