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

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
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) in s(test.mixin_application_test), top-level)' ,
ahe 2013/10/15 06:58:48 Long line, more below.
rmacnak 2013/10/15 16:55:30 Got 'em.
123 'Class(s(test.model.C with test.mixin_test.Mixin)$owner, top-level)', 123 'Class(s(test.model.C with test.mixin_application_test.Mixin)$owner, top-l evel)',
124 'Class(s(C) in s(test.model), top-level)', 124 'Class(s(C) in s(test.model), top-level)',
125 'Class(s(B) in s(test.model), top-level)', 125 'Class(s(B) in s(test.model), top-level)',
126 'Class(s(A) in s(test.model), top-level)', 126 'Class(s(A) in s(test.model), top-level)',
127 'Class(s(Object) in s(dart.core), top-level)', 127 'Class(s(Object) in s(dart.core), top-level)',
128 ]); 128 ]);
129 129
130 owner = 'Mixin2'; 130 owner = 'Mixin2';
131 owner = 'MixinApplicationA'; /// 01: ok 131 owner = 'MixinApplicationA'; /// 01: ok
132 expect( 132 expect(
133 '{i2: Variable(s(i2) in s($owner)),' 133 '{i2: Variable(s(i2) in s($owner)),'
134 ' m2: Method(s(m2) in s($owner))}', 134 ' m2: Method(s(m2) in s($owner))}',
135 reflectClass(MixinApplicationA).members); 135 reflectClass(MixinApplicationA).members);
136 136
137 expect( 137 expect(
138 '{MixinApplicationA: Method(s(MixinApplicationA) in s(MixinApplicationA),' 138 '{MixinApplicationA: Method(s(MixinApplicationA) in s(MixinApplicationA),'
139 ' constructor)}', 139 ' constructor)}',
140 reflectClass(MixinApplicationA).constructors); 140 reflectClass(MixinApplicationA).constructors);
141 141
142 expect( 142 expect(
143 '{i: Variable(s(i) in s(Mixin)),' 143 '{i: Variable(s(i) in s(Mixin)),'
144 ' m: Method(s(m) in s(Mixin))}', 144 ' m: Method(s(m) in s(Mixin))}',
145 reflectClass(MixinApplicationA).superclass.members); 145 reflectClass(MixinApplicationA).superclass.members);
146 146
147 String name = 'test.model.C with test.mixin_test.Mixin'; 147 String name = 'test.model.C with test.mixin_application_test.Mixin';
148 name = 'Mixin'; /// 01: ok 148 name = 'Mixin'; /// 01: ok
149 expect( 149 expect(
150 '{$name:' 150 '{$name:'
151 ' Method(s($name)' 151 ' Method(s($name)'
152 ' in s($name), constructor)}', 152 ' in s($name), constructor)}',
153 reflectClass(MixinApplicationA).superclass.constructors); 153 reflectClass(MixinApplicationA).superclass.constructors);
154 154
155 expectSame( 155 expectSame(
156 reflectClass(C), 156 reflectClass(C),
157 reflectClass(MixinApplicationA).superclass.superclass); 157 reflectClass(MixinApplicationA).superclass.superclass);
158 } 158 }
159 159
160 testUnusedMixinApplication() { 160 testUnusedMixinApplication() {
161 checkClass(UnusedMixinApplication, [ 161 checkClass(UnusedMixinApplication, [
162 'Class(s(UnusedMixinApplication) in s(test.mixin_test), top-level)', 162 'Class(s(UnusedMixinApplication) in s(test.mixin_application_test), top-le vel)',
163 'Class(s(C) in s(test.model), top-level)', 163 'Class(s(C) in s(test.model), top-level)',
164 'Class(s(B) in s(test.model), top-level)', 164 'Class(s(B) in s(test.model), top-level)',
165 'Class(s(A) in s(test.model), top-level)', 165 'Class(s(A) in s(test.model), top-level)',
166 'Class(s(Object) in s(dart.core), top-level)', 166 'Class(s(Object) in s(dart.core), top-level)',
167 ]); 167 ]);
168 168
169 String owner = 'Mixin'; 169 String owner = 'Mixin';
170 owner = 'UnusedMixinApplication'; /// 01: ok 170 owner = 'UnusedMixinApplication'; /// 01: ok
171 expect( 171 expect(
172 '{i: Variable(s(i) in s($owner)),' 172 '{i: Variable(s(i) in s($owner)),'
173 ' m: Method(s(m) in s($owner))}', 173 ' m: Method(s(m) in s($owner))}',
174 reflectClass(UnusedMixinApplication).members); 174 reflectClass(UnusedMixinApplication).members);
175 175
176 expect( 176 expect(
177 '{UnusedMixinApplication: Method(s(UnusedMixinApplication)' 177 '{UnusedMixinApplication: Method(s(UnusedMixinApplication)'
178 ' in s(UnusedMixinApplication), constructor)}', 178 ' in s(UnusedMixinApplication), constructor)}',
179 reflectClass(UnusedMixinApplication).constructors); 179 reflectClass(UnusedMixinApplication).constructors);
180 180
181 expectSame(reflectClass(C), reflectClass(UnusedMixinApplication).superclass); 181 expectSame(reflectClass(C), reflectClass(UnusedMixinApplication).superclass);
182 } 182 }
183 183
184 testSubclass() { 184 testSubclass() {
185 String owner = ' in s(test.mixin_test)'; 185 String owner = ' in s(test.mixin_application_test)';
186 owner = ''; /// 01: ok 186 owner = ''; /// 01: ok
187 checkClass(Subclass, [ 187 checkClass(Subclass, [
188 'Class(s(Subclass) in s(test.mixin_test), top-level)', 188 '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)', 189 'Class(s(test.model.C with test.mixin_application_test.Mixin)$owner, top-l evel)',
190 'Class(s(C) in s(test.model), top-level)', 190 'Class(s(C) in s(test.model), top-level)',
191 'Class(s(B) in s(test.model), top-level)', 191 'Class(s(B) in s(test.model), top-level)',
192 'Class(s(A) in s(test.model), top-level)', 192 'Class(s(A) in s(test.model), top-level)',
193 'Class(s(Object) in s(dart.core), top-level)', 193 'Class(s(Object) in s(dart.core), top-level)',
194 ]); 194 ]);
195 195
196 expect( 196 expect(
197 '{f: Method(s(f) in s(Subclass))}', 197 '{f: Method(s(f) in s(Subclass))}',
198 reflectClass(Subclass).members); 198 reflectClass(Subclass).members);
199 199
200 expect( 200 expect(
201 '{Subclass: Method(s(Subclass) in s(Subclass), constructor)}', 201 '{Subclass: Method(s(Subclass) in s(Subclass), constructor)}',
202 reflectClass(Subclass).constructors); 202 reflectClass(Subclass).constructors);
203 203
204 expect( 204 expect(
205 '{i: Variable(s(i) in s(Mixin)),' 205 '{i: Variable(s(i) in s(Mixin)),'
206 ' m: Method(s(m) in s(Mixin))}', 206 ' m: Method(s(m) in s(Mixin))}',
207 reflectClass(Subclass).superclass.members); 207 reflectClass(Subclass).superclass.members);
208 208
209 String name = 'test.model.C with test.mixin_test.Mixin'; 209 String name = 'test.model.C with test.mixin_application_test.Mixin';
210 name = 'Mixin'; /// 01: ok 210 name = 'Mixin'; /// 01: ok
211 expect( 211 expect(
212 '{$name:' 212 '{$name:'
213 ' Method(s($name)' 213 ' Method(s($name)'
214 ' in s($name), constructor)}', 214 ' in s($name), constructor)}',
215 reflectClass(Subclass).superclass.constructors); 215 reflectClass(Subclass).superclass.constructors);
216 216
217 expectSame( 217 expectSame(
218 reflectClass(C), 218 reflectClass(C),
219 reflectClass(Subclass).superclass.superclass); 219 reflectClass(Subclass).superclass.superclass);
220 } 220 }
221 221
222 testSubclass2() { 222 testSubclass2() {
223 checkClass(Subclass2, [ 223 checkClass(Subclass2, [
224 'Class(s(Subclass2) in s(test.mixin_test), top-level)', 224 'Class(s(Subclass2) in s(test.mixin_application_test), top-level)',
225 'Class(s(MixinApplication) in s(test.mixin_test), top-level)', 225 'Class(s(MixinApplication) in s(test.mixin_application_test), top-level)',
226 'Class(s(C) in s(test.model), top-level)', 226 'Class(s(C) in s(test.model), top-level)',
227 'Class(s(B) in s(test.model), top-level)', 227 'Class(s(B) in s(test.model), top-level)',
228 'Class(s(A) in s(test.model), top-level)', 228 'Class(s(A) in s(test.model), top-level)',
229 'Class(s(Object) in s(dart.core), top-level)', 229 'Class(s(Object) in s(dart.core), top-level)',
230 ]); 230 ]);
231 231
232 expect( 232 expect(
233 '{g: Method(s(g) in s(Subclass2))}', 233 '{g: Method(s(g) in s(Subclass2))}',
234 reflectClass(Subclass2).members); 234 reflectClass(Subclass2).members);
235 235
236 expect( 236 expect(
237 '{Subclass2: Method(s(Subclass2) in s(Subclass2), constructor)}', 237 '{Subclass2: Method(s(Subclass2) in s(Subclass2), constructor)}',
238 reflectClass(Subclass2).constructors); 238 reflectClass(Subclass2).constructors);
239 239
240 expectSame( 240 expectSame(
241 reflectClass(MixinApplication), 241 reflectClass(MixinApplication),
242 reflectClass(Subclass2).superclass); 242 reflectClass(Subclass2).superclass);
243 } 243 }
244 244
245 testSubclassA() { 245 testSubclassA() {
246 // TODO(ahe): I don't think an anonymous mixin has an owner. 246 // TODO(ahe): I don't think an anonymous mixin has an owner.
247 String owner = ' in s(test.mixin_test)'; 247 String owner = ' in s(test.mixin_application_test)';
248 owner = ''; /// 01: ok 248 owner = ''; /// 01: ok
249 checkClass(SubclassA, [ 249 checkClass(SubclassA, [
250 'Class(s(SubclassA) in s(test.mixin_test), top-level)', 250 '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)' 251 'Class(s(test.model.C with test.mixin_application_test.Mixin, test.mixin_a pplication_test.Mixin2)'
252 '$owner, top-level)', 252 '$owner, top-level)',
253 'Class(s(test.model.C with test.mixin_test.Mixin)$owner, top-level)', 253 'Class(s(test.model.C with test.mixin_application_test.Mixin)$owner, top-l evel)',
254 'Class(s(C) in s(test.model), top-level)', 254 'Class(s(C) in s(test.model), top-level)',
255 'Class(s(B) in s(test.model), top-level)', 255 'Class(s(B) in s(test.model), top-level)',
256 'Class(s(A) in s(test.model), top-level)', 256 'Class(s(A) in s(test.model), top-level)',
257 'Class(s(Object) in s(dart.core), top-level)', 257 'Class(s(Object) in s(dart.core), top-level)',
258 ]); 258 ]);
259 259
260 expect( 260 expect(
261 '{fa: Method(s(fa) in s(SubclassA))}', 261 '{fa: Method(s(fa) in s(SubclassA))}',
262 reflectClass(SubclassA).members); 262 reflectClass(SubclassA).members);
263 263
264 expect( 264 expect(
265 '{SubclassA: Method(s(SubclassA) in s(SubclassA), constructor)}', 265 '{SubclassA: Method(s(SubclassA) in s(SubclassA), constructor)}',
266 reflectClass(SubclassA).constructors); 266 reflectClass(SubclassA).constructors);
267 267
268 expect( 268 expect(
269 '{i2: Variable(s(i2) in s(Mixin2)),' 269 '{i2: Variable(s(i2) in s(Mixin2)),'
270 ' m2: Method(s(m2) in s(Mixin2))}', 270 ' m2: Method(s(m2) in s(Mixin2))}',
271 reflectClass(SubclassA).superclass.members); 271 reflectClass(SubclassA).superclass.members);
272 272
273 String name = 273 String name =
274 'test.model.C with test.mixin_test.Mixin, test.mixin_test.Mixin2'; 274 'test.model.C with test.mixin_application_test.Mixin, test.mixin_applicati on_test.Mixin2';
275 name = 'Mixin2'; /// 01: ok 275 name = 'Mixin2'; /// 01: ok
276 expect( 276 expect(
277 '{$name: Method(s($name) in s($name), constructor)}', 277 '{$name: Method(s($name) in s($name), constructor)}',
278 reflectClass(SubclassA).superclass.constructors); 278 reflectClass(SubclassA).superclass.constructors);
279 279
280 expect( 280 expect(
281 '{i: Variable(s(i) in s(Mixin)),' 281 '{i: Variable(s(i) in s(Mixin)),'
282 ' m: Method(s(m) in s(Mixin))}', 282 ' m: Method(s(m) in s(Mixin))}',
283 reflectClass(SubclassA).superclass.superclass.members); 283 reflectClass(SubclassA).superclass.superclass.members);
284 284
285 name = 'test.model.C with test.mixin_test.Mixin'; 285 name = 'test.model.C with test.mixin_application_test.Mixin';
286 name = 'Mixin'; /// 01: ok 286 name = 'Mixin'; /// 01: ok
287 expect( 287 expect(
288 '{$name:' 288 '{$name:'
289 ' Method(s($name)' 289 ' Method(s($name)'
290 ' in s($name), constructor)}', 290 ' in s($name), constructor)}',
291 reflectClass(SubclassA).superclass.superclass.constructors); 291 reflectClass(SubclassA).superclass.superclass.constructors);
292 292
293 expectSame( 293 expectSame(
294 reflectClass(C), 294 reflectClass(C),
295 reflectClass(SubclassA).superclass.superclass.superclass); 295 reflectClass(SubclassA).superclass.superclass.superclass);
296 } 296 }
297 297
298 testSubclass2A() { 298 testSubclass2A() {
299 // TODO(ahe): I don't think an anonymous mixin has an owner. 299 // TODO(ahe): I don't think an anonymous mixin has an owner.
300 String owner = ' in s(test.mixin_test)'; 300 String owner = ' in s(test.mixin_application_test)';
301 owner = ''; /// 01: ok 301 owner = ''; /// 01: ok
302 checkClass(Subclass2A, [ 302 checkClass(Subclass2A, [
303 'Class(s(Subclass2A) in s(test.mixin_test), top-level)', 303 'Class(s(Subclass2A) in s(test.mixin_application_test), top-level)',
304 'Class(s(MixinApplicationA) in s(test.mixin_test), top-level)', 304 'Class(s(MixinApplicationA) in s(test.mixin_application_test), top-level)' ,
305 'Class(s(test.model.C with test.mixin_test.Mixin)$owner,' 305 'Class(s(test.model.C with test.mixin_application_test.Mixin)$owner,'
306 ' top-level)', 306 ' top-level)',
307 'Class(s(C) in s(test.model), top-level)', 307 'Class(s(C) in s(test.model), top-level)',
308 'Class(s(B) in s(test.model), top-level)', 308 'Class(s(B) in s(test.model), top-level)',
309 'Class(s(A) in s(test.model), top-level)', 309 'Class(s(A) in s(test.model), top-level)',
310 'Class(s(Object) in s(dart.core), top-level)', 310 'Class(s(Object) in s(dart.core), top-level)',
311 ]); 311 ]);
312 312
313 expect( 313 expect(
314 '{ga: Method(s(ga) in s(Subclass2A))}', 314 '{ga: Method(s(ga) in s(Subclass2A))}',
315 reflectClass(Subclass2A).members); 315 reflectClass(Subclass2A).members);
(...skipping 10 matching lines...) Expand all
326 testMixin(); 326 testMixin();
327 testMixin2(); 327 testMixin2();
328 testMixinApplication(); 328 testMixinApplication();
329 testMixinApplicationA(); 329 testMixinApplicationA();
330 testUnusedMixinApplication(); 330 testUnusedMixinApplication();
331 testSubclass(); 331 testSubclass();
332 testSubclass2(); 332 testSubclass2();
333 testSubclassA(); 333 testSubclassA();
334 testSubclass2A(); 334 testSubclass2A();
335 } 335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698