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

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

Issue 27275002: Add test for ClassMirror.mixin. Rename the mixin application test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « tests/lib/lib.status ('k') | 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
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 // This test uses the multi-test "ok" feature to create two positive tests from 5 // This test uses the multi-test "ok" feature to create two positive tests from
6 // one file. One of these tests fail on dart2js, but pass on the VM, or vice 6 // one file. One of these tests fail on dart2js, but pass on the VM, or vice
7 // versa. 7 // versa.
8 // TODO(ahe): When both implementations agree, remove the multi-test parts. 8 // TODO(ahe): When both implementations agree, remove the multi-test parts.
9 9
10 library test.mixin_test; 10 library test.mixin_application_test;
11 11
12 import 'dart:mirrors'; 12 import 'dart:mirrors';
13 13
14 import 'package:expect/expect.dart'; 14 import 'package:expect/expect.dart';
15 15
16 import 'model.dart'; 16 import 'model.dart';
17 import 'stringify.dart'; 17 import 'stringify.dart';
18 18
19 class Mixin { 19 class Mixin {
20 int i; 20 int i;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 expectSame(ClassMirror a, ClassMirror b) { 58 expectSame(ClassMirror a, ClassMirror b) {
59 Expect.equals(a, b); 59 Expect.equals(a, b);
60 expect(stringify(a), b); 60 expect(stringify(a), b);
61 expect(stringify(b), a); 61 expect(stringify(b), a);
62 } 62 }
63 63
64 testMixin() { 64 testMixin() {
65 checkClass(Mixin, [ 65 checkClass(Mixin, [
66 'Class(s(Mixin) in s(test.mixin_test), top-level)', 66 'Class(s(Mixin) in s(test.mixin_application_test), top-level)',
67 'Class(s(Object) in s(dart.core), top-level)', 67 'Class(s(Object) in s(dart.core), top-level)',
68 ]); 68 ]);
69 69
70 expect( 70 expect(
71 '{i: Variable(s(i) in s(Mixin)),' 71 '{i: Variable(s(i) in s(Mixin)),'
72 ' m: Method(s(m) in s(Mixin))}', 72 ' m: Method(s(m) in s(Mixin))}',
73 reflectClass(Mixin).members); 73 reflectClass(Mixin).members);
74 74
75 expect('{Mixin: Method(s(Mixin) in s(Mixin), constructor)}', 75 expect('{Mixin: Method(s(Mixin) in s(Mixin), constructor)}',
76 reflectClass(Mixin).constructors); 76 reflectClass(Mixin).constructors);
77 } 77 }
78 78
79 testMixin2() { 79 testMixin2() {
80 checkClass(Mixin2, [ 80 checkClass(Mixin2, [
81 'Class(s(Mixin2) in s(test.mixin_test), top-level)', 81 'Class(s(Mixin2) in s(test.mixin_application_test), top-level)',
82 'Class(s(Object) in s(dart.core), top-level)', 82 'Class(s(Object) in s(dart.core), top-level)',
83 ]); 83 ]);
84 84
85 expect( 85 expect(
86 '{i2: Variable(s(i2) in s(Mixin2)),' 86 '{i2: Variable(s(i2) in s(Mixin2)),'
87 ' m2: Method(s(m2) in s(Mixin2))}', 87 ' m2: Method(s(m2) in s(Mixin2))}',
88 reflectClass(Mixin2).members); 88 reflectClass(Mixin2).members);
89 89
90 expect('{Mixin2: Method(s(Mixin2) in s(Mixin2), constructor)}', 90 expect('{Mixin2: Method(s(Mixin2) in s(Mixin2), constructor)}',
91 reflectClass(Mixin2).constructors); 91 reflectClass(Mixin2).constructors);
92 } 92 }
93 93
94 testMixinApplication() { 94 testMixinApplication() {
95 checkClass(MixinApplication, [ 95 checkClass(MixinApplication, [
96 'Class(s(MixinApplication) in s(test.mixin_test), top-level)', 96 'Class(s(MixinApplication) in s(test.mixin_application_test), top-level)',
97 'Class(s(C) in s(test.model), top-level)', 97 'Class(s(C) in s(test.model), top-level)',
98 'Class(s(B) in s(test.model), top-level)', 98 'Class(s(B) in s(test.model), top-level)',
99 'Class(s(A) in s(test.model), top-level)', 99 'Class(s(A) in s(test.model), top-level)',
100 'Class(s(Object) in s(dart.core), top-level)', 100 'Class(s(Object) in s(dart.core), top-level)',
101 ]); 101 ]);
102 102
103 String owner = 'Mixin'; 103 String owner = 'Mixin';
104 owner = 'MixinApplication'; /// 01: ok 104 owner = 'MixinApplication'; /// 01: ok
105 expect( 105 expect(
106 '{i: Variable(s(i) in s($owner)),' 106 '{i: Variable(s(i) in s($owner)),'
107 ' m: Method(s(m) in s($owner))}', 107 ' m: Method(s(m) in s($owner))}',
108 reflectClass(MixinApplication).members); 108 reflectClass(MixinApplication).members);
109 109
110 expect('{MixinApplication: Method(s(MixinApplication) in s(MixinApplication),' 110 expect('{MixinApplication: Method(s(MixinApplication) in s(MixinApplication),'
111 ' constructor)}', 111 ' constructor)}',
112 reflectClass(MixinApplication).constructors); 112 reflectClass(MixinApplication).constructors);
113 113
114 expectSame(reflectClass(C), reflectClass(MixinApplication).superclass); 114 expectSame(reflectClass(C), reflectClass(MixinApplication).superclass);
115 } 115 }
116 116
117 testMixinApplicationA() { 117 testMixinApplicationA() {
118 // TODO(ahe): I don't think an anonymous mixin has an owner. 118 // TODO(ahe): I don't think an anonymous mixin has an owner.
119 String owner = ' in s(test.mixin_test)'; 119 String owner = ' in s(test.mixin_application_test)';
120 owner = ''; /// 01: ok 120 owner = ''; /// 01: ok
121 checkClass(MixinApplicationA, [ 121 checkClass(MixinApplicationA, [
122 'Class(s(MixinApplicationA) in s(test.mixin_test), top-level)', 122 'Class(s(MixinApplicationA)'
123 'Class(s(test.model.C with test.mixin_test.Mixin)$owner, top-level)', 123 ' in s(test.mixin_application_test), top-level)',
124 'Class(s(test.model.C with test.mixin_application_test.Mixin)'
125 '$owner, top-level)',
124 'Class(s(C) in s(test.model), top-level)', 126 'Class(s(C) in s(test.model), top-level)',
125 'Class(s(B) in s(test.model), top-level)', 127 'Class(s(B) in s(test.model), top-level)',
126 'Class(s(A) in s(test.model), top-level)', 128 'Class(s(A) in s(test.model), top-level)',
127 'Class(s(Object) in s(dart.core), top-level)', 129 'Class(s(Object) in s(dart.core), top-level)',
128 ]); 130 ]);
129 131
130 owner = 'Mixin2'; 132 owner = 'Mixin2';
131 owner = 'MixinApplicationA'; /// 01: ok 133 owner = 'MixinApplicationA'; /// 01: ok
132 expect( 134 expect(
133 '{i2: Variable(s(i2) in s($owner)),' 135 '{i2: Variable(s(i2) in s($owner)),'
134 ' m2: Method(s(m2) in s($owner))}', 136 ' m2: Method(s(m2) in s($owner))}',
135 reflectClass(MixinApplicationA).members); 137 reflectClass(MixinApplicationA).members);
136 138
137 expect( 139 expect(
138 '{MixinApplicationA: Method(s(MixinApplicationA) in s(MixinApplicationA),' 140 '{MixinApplicationA: Method(s(MixinApplicationA) in s(MixinApplicationA),'
139 ' constructor)}', 141 ' constructor)}',
140 reflectClass(MixinApplicationA).constructors); 142 reflectClass(MixinApplicationA).constructors);
141 143
142 expect( 144 expect(
143 '{i: Variable(s(i) in s(Mixin)),' 145 '{i: Variable(s(i) in s(Mixin)),'
144 ' m: Method(s(m) in s(Mixin))}', 146 ' m: Method(s(m) in s(Mixin))}',
145 reflectClass(MixinApplicationA).superclass.members); 147 reflectClass(MixinApplicationA).superclass.members);
146 148
147 String name = 'test.model.C with test.mixin_test.Mixin'; 149 String name = 'test.model.C with test.mixin_application_test.Mixin';
148 name = 'Mixin'; /// 01: ok 150 name = 'Mixin'; /// 01: ok
149 expect( 151 expect(
150 '{$name:' 152 '{$name:'
151 ' Method(s($name)' 153 ' Method(s($name)'
152 ' in s($name), constructor)}', 154 ' in s($name), constructor)}',
153 reflectClass(MixinApplicationA).superclass.constructors); 155 reflectClass(MixinApplicationA).superclass.constructors);
154 156
155 expectSame( 157 expectSame(
156 reflectClass(C), 158 reflectClass(C),
157 reflectClass(MixinApplicationA).superclass.superclass); 159 reflectClass(MixinApplicationA).superclass.superclass);
158 } 160 }
159 161
160 testUnusedMixinApplication() { 162 testUnusedMixinApplication() {
161 checkClass(UnusedMixinApplication, [ 163 checkClass(UnusedMixinApplication, [
162 'Class(s(UnusedMixinApplication) in s(test.mixin_test), top-level)', 164 'Class(s(UnusedMixinApplication) in s(test.mixin_application_test),'
165 ' top-level)',
163 'Class(s(C) in s(test.model), top-level)', 166 'Class(s(C) in s(test.model), top-level)',
164 'Class(s(B) in s(test.model), top-level)', 167 'Class(s(B) in s(test.model), top-level)',
165 'Class(s(A) in s(test.model), top-level)', 168 'Class(s(A) in s(test.model), top-level)',
166 'Class(s(Object) in s(dart.core), top-level)', 169 'Class(s(Object) in s(dart.core), top-level)',
167 ]); 170 ]);
168 171
169 String owner = 'Mixin'; 172 String owner = 'Mixin';
170 owner = 'UnusedMixinApplication'; /// 01: ok 173 owner = 'UnusedMixinApplication'; /// 01: ok
171 expect( 174 expect(
172 '{i: Variable(s(i) in s($owner)),' 175 '{i: Variable(s(i) in s($owner)),'
173 ' m: Method(s(m) in s($owner))}', 176 ' m: Method(s(m) in s($owner))}',
174 reflectClass(UnusedMixinApplication).members); 177 reflectClass(UnusedMixinApplication).members);
175 178
176 expect( 179 expect(
177 '{UnusedMixinApplication: Method(s(UnusedMixinApplication)' 180 '{UnusedMixinApplication: Method(s(UnusedMixinApplication)'
178 ' in s(UnusedMixinApplication), constructor)}', 181 ' in s(UnusedMixinApplication), constructor)}',
179 reflectClass(UnusedMixinApplication).constructors); 182 reflectClass(UnusedMixinApplication).constructors);
180 183
181 expectSame(reflectClass(C), reflectClass(UnusedMixinApplication).superclass); 184 expectSame(reflectClass(C), reflectClass(UnusedMixinApplication).superclass);
182 } 185 }
183 186
184 testSubclass() { 187 testSubclass() {
185 String owner = ' in s(test.mixin_test)'; 188 String owner = ' in s(test.mixin_application_test)';
186 owner = ''; /// 01: ok 189 owner = ''; /// 01: ok
187 checkClass(Subclass, [ 190 checkClass(Subclass, [
188 'Class(s(Subclass) in s(test.mixin_test), top-level)', 191 'Class(s(Subclass) in s(test.mixin_application_test), top-level)',
189 'Class(s(test.model.C with test.mixin_test.Mixin)$owner, top-level)', 192 'Class(s(test.model.C with test.mixin_application_test.Mixin)'
193 '$owner, top-level)',
190 'Class(s(C) in s(test.model), top-level)', 194 'Class(s(C) in s(test.model), top-level)',
191 'Class(s(B) in s(test.model), top-level)', 195 'Class(s(B) in s(test.model), top-level)',
192 'Class(s(A) in s(test.model), top-level)', 196 'Class(s(A) in s(test.model), top-level)',
193 'Class(s(Object) in s(dart.core), top-level)', 197 'Class(s(Object) in s(dart.core), top-level)',
194 ]); 198 ]);
195 199
196 expect( 200 expect(
197 '{f: Method(s(f) in s(Subclass))}', 201 '{f: Method(s(f) in s(Subclass))}',
198 reflectClass(Subclass).members); 202 reflectClass(Subclass).members);
199 203
200 expect( 204 expect(
201 '{Subclass: Method(s(Subclass) in s(Subclass), constructor)}', 205 '{Subclass: Method(s(Subclass) in s(Subclass), constructor)}',
202 reflectClass(Subclass).constructors); 206 reflectClass(Subclass).constructors);
203 207
204 expect( 208 expect(
205 '{i: Variable(s(i) in s(Mixin)),' 209 '{i: Variable(s(i) in s(Mixin)),'
206 ' m: Method(s(m) in s(Mixin))}', 210 ' m: Method(s(m) in s(Mixin))}',
207 reflectClass(Subclass).superclass.members); 211 reflectClass(Subclass).superclass.members);
208 212
209 String name = 'test.model.C with test.mixin_test.Mixin'; 213 String name = 'test.model.C with test.mixin_application_test.Mixin';
210 name = 'Mixin'; /// 01: ok 214 name = 'Mixin'; /// 01: ok
211 expect( 215 expect(
212 '{$name:' 216 '{$name:'
213 ' Method(s($name)' 217 ' Method(s($name)'
214 ' in s($name), constructor)}', 218 ' in s($name), constructor)}',
215 reflectClass(Subclass).superclass.constructors); 219 reflectClass(Subclass).superclass.constructors);
216 220
217 expectSame( 221 expectSame(
218 reflectClass(C), 222 reflectClass(C),
219 reflectClass(Subclass).superclass.superclass); 223 reflectClass(Subclass).superclass.superclass);
220 } 224 }
221 225
222 testSubclass2() { 226 testSubclass2() {
223 checkClass(Subclass2, [ 227 checkClass(Subclass2, [
224 'Class(s(Subclass2) in s(test.mixin_test), top-level)', 228 'Class(s(Subclass2) in s(test.mixin_application_test), top-level)',
225 'Class(s(MixinApplication) in s(test.mixin_test), top-level)', 229 'Class(s(MixinApplication) in s(test.mixin_application_test), top-level)',
226 'Class(s(C) in s(test.model), top-level)', 230 'Class(s(C) in s(test.model), top-level)',
227 'Class(s(B) in s(test.model), top-level)', 231 'Class(s(B) in s(test.model), top-level)',
228 'Class(s(A) in s(test.model), top-level)', 232 'Class(s(A) in s(test.model), top-level)',
229 'Class(s(Object) in s(dart.core), top-level)', 233 'Class(s(Object) in s(dart.core), top-level)',
230 ]); 234 ]);
231 235
232 expect( 236 expect(
233 '{g: Method(s(g) in s(Subclass2))}', 237 '{g: Method(s(g) in s(Subclass2))}',
234 reflectClass(Subclass2).members); 238 reflectClass(Subclass2).members);
235 239
236 expect( 240 expect(
237 '{Subclass2: Method(s(Subclass2) in s(Subclass2), constructor)}', 241 '{Subclass2: Method(s(Subclass2) in s(Subclass2), constructor)}',
238 reflectClass(Subclass2).constructors); 242 reflectClass(Subclass2).constructors);
239 243
240 expectSame( 244 expectSame(
241 reflectClass(MixinApplication), 245 reflectClass(MixinApplication),
242 reflectClass(Subclass2).superclass); 246 reflectClass(Subclass2).superclass);
243 } 247 }
244 248
245 testSubclassA() { 249 testSubclassA() {
246 // TODO(ahe): I don't think an anonymous mixin has an owner. 250 // TODO(ahe): I don't think an anonymous mixin has an owner.
247 String owner = ' in s(test.mixin_test)'; 251 String owner = ' in s(test.mixin_application_test)';
248 owner = ''; /// 01: ok 252 owner = ''; /// 01: ok
249 checkClass(SubclassA, [ 253 checkClass(SubclassA, [
250 'Class(s(SubclassA) in s(test.mixin_test), top-level)', 254 'Class(s(SubclassA) in s(test.mixin_application_test), top-level)',
251 'Class(s(test.model.C with test.mixin_test.Mixin, test.mixin_test.Mixin2)' 255 'Class(s(test.model.C with test.mixin_application_test.Mixin,'
252 '$owner, top-level)', 256 ' test.mixin_application_test.Mixin2)$owner, top-level)',
253 'Class(s(test.model.C with test.mixin_test.Mixin)$owner, top-level)', 257 'Class(s(test.model.C with test.mixin_application_test.Mixin)$owner,'
258 ' top-level)',
254 'Class(s(C) in s(test.model), top-level)', 259 'Class(s(C) in s(test.model), top-level)',
255 'Class(s(B) in s(test.model), top-level)', 260 'Class(s(B) in s(test.model), top-level)',
256 'Class(s(A) in s(test.model), top-level)', 261 'Class(s(A) in s(test.model), top-level)',
257 'Class(s(Object) in s(dart.core), top-level)', 262 'Class(s(Object) in s(dart.core), top-level)',
258 ]); 263 ]);
259 264
260 expect( 265 expect(
261 '{fa: Method(s(fa) in s(SubclassA))}', 266 '{fa: Method(s(fa) in s(SubclassA))}',
262 reflectClass(SubclassA).members); 267 reflectClass(SubclassA).members);
263 268
264 expect( 269 expect(
265 '{SubclassA: Method(s(SubclassA) in s(SubclassA), constructor)}', 270 '{SubclassA: Method(s(SubclassA) in s(SubclassA), constructor)}',
266 reflectClass(SubclassA).constructors); 271 reflectClass(SubclassA).constructors);
267 272
268 expect( 273 expect(
269 '{i2: Variable(s(i2) in s(Mixin2)),' 274 '{i2: Variable(s(i2) in s(Mixin2)),'
270 ' m2: Method(s(m2) in s(Mixin2))}', 275 ' m2: Method(s(m2) in s(Mixin2))}',
271 reflectClass(SubclassA).superclass.members); 276 reflectClass(SubclassA).superclass.members);
272 277
273 String name = 278 String name =
274 'test.model.C with test.mixin_test.Mixin, test.mixin_test.Mixin2'; 279 'test.model.C with test.mixin_application_test.Mixin,'
280 ' test.mixin_application_test.Mixin2';
275 name = 'Mixin2'; /// 01: ok 281 name = 'Mixin2'; /// 01: ok
276 expect( 282 expect(
277 '{$name: Method(s($name) in s($name), constructor)}', 283 '{$name: Method(s($name) in s($name), constructor)}',
278 reflectClass(SubclassA).superclass.constructors); 284 reflectClass(SubclassA).superclass.constructors);
279 285
280 expect( 286 expect(
281 '{i: Variable(s(i) in s(Mixin)),' 287 '{i: Variable(s(i) in s(Mixin)),'
282 ' m: Method(s(m) in s(Mixin))}', 288 ' m: Method(s(m) in s(Mixin))}',
283 reflectClass(SubclassA).superclass.superclass.members); 289 reflectClass(SubclassA).superclass.superclass.members);
284 290
285 name = 'test.model.C with test.mixin_test.Mixin'; 291 name = 'test.model.C with test.mixin_application_test.Mixin';
286 name = 'Mixin'; /// 01: ok 292 name = 'Mixin'; /// 01: ok
287 expect( 293 expect(
288 '{$name:' 294 '{$name:'
289 ' Method(s($name)' 295 ' Method(s($name)'
290 ' in s($name), constructor)}', 296 ' in s($name), constructor)}',
291 reflectClass(SubclassA).superclass.superclass.constructors); 297 reflectClass(SubclassA).superclass.superclass.constructors);
292 298
293 expectSame( 299 expectSame(
294 reflectClass(C), 300 reflectClass(C),
295 reflectClass(SubclassA).superclass.superclass.superclass); 301 reflectClass(SubclassA).superclass.superclass.superclass);
296 } 302 }
297 303
298 testSubclass2A() { 304 testSubclass2A() {
299 // TODO(ahe): I don't think an anonymous mixin has an owner. 305 // TODO(ahe): I don't think an anonymous mixin has an owner.
300 String owner = ' in s(test.mixin_test)'; 306 String owner = ' in s(test.mixin_application_test)';
301 owner = ''; /// 01: ok 307 owner = ''; /// 01: ok
302 checkClass(Subclass2A, [ 308 checkClass(Subclass2A, [
303 'Class(s(Subclass2A) in s(test.mixin_test), top-level)', 309 'Class(s(Subclass2A) in s(test.mixin_application_test), top-level)',
304 'Class(s(MixinApplicationA) in s(test.mixin_test), top-level)', 310 'Class(s(MixinApplicationA) in s(test.mixin_application_test),'
305 'Class(s(test.model.C with test.mixin_test.Mixin)$owner,' 311 ' top-level)',
312 'Class(s(test.model.C with test.mixin_application_test.Mixin)$owner,'
306 ' top-level)', 313 ' top-level)',
307 'Class(s(C) in s(test.model), top-level)', 314 'Class(s(C) in s(test.model), top-level)',
308 'Class(s(B) in s(test.model), top-level)', 315 'Class(s(B) in s(test.model), top-level)',
309 'Class(s(A) in s(test.model), top-level)', 316 'Class(s(A) in s(test.model), top-level)',
310 'Class(s(Object) in s(dart.core), top-level)', 317 'Class(s(Object) in s(dart.core), top-level)',
311 ]); 318 ]);
312 319
313 expect( 320 expect(
314 '{ga: Method(s(ga) in s(Subclass2A))}', 321 '{ga: Method(s(ga) in s(Subclass2A))}',
315 reflectClass(Subclass2A).members); 322 reflectClass(Subclass2A).members);
(...skipping 10 matching lines...) Expand all
326 testMixin(); 333 testMixin();
327 testMixin2(); 334 testMixin2();
328 testMixinApplication(); 335 testMixinApplication();
329 testMixinApplicationA(); 336 testMixinApplicationA();
330 testUnusedMixinApplication(); 337 testUnusedMixinApplication();
331 testSubclass(); 338 testSubclass();
332 testSubclass2(); 339 testSubclass2();
333 testSubclassA(); 340 testSubclassA();
334 testSubclass2A(); 341 testSubclass2A();
335 } 342 }
OLDNEW
« no previous file with comments | « tests/lib/lib.status ('k') | tests/lib/mirrors/mixin_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698