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

Side by Side Diff: packages/smoke/test/codegen/recorder_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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
(Empty)
1 // Copyright (c) 2014, 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 library smoke.test.codegen.recorder_test;
6
7 import 'package:analyzer/src/generated/element.dart';
8 import 'package:smoke/codegen/generator.dart';
9 import 'package:smoke/codegen/recorder.dart';
10 import 'package:test/test.dart';
11
12 import 'common.dart' show checkResults;
13 import 'testing_resolver_utils.dart' show initAnalyzer;
14
15 main() {
16 var provider = initAnalyzer(_SOURCES);
17 var generator;
18 var recorder;
19 setUp(() {
20 generator = new SmokeCodeGenerator();
21 recorder = new Recorder(generator, resolveImportUrl);
22 });
23
24 group('parents', () {
25 test('simple subclassing', () {
26 var lib = provider.libraryFor('/a.dart');
27 recorder.lookupParent(lib.getType('A'));
28 recorder.lookupParent(lib.getType('C'));
29
30 checkResults(generator,
31 imports: [
32 "import '/a.dart' as smoke_0;",
33 "import '/b.dart' as smoke_1;",
34 ],
35 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
36 ' checkedMode: false,\n'
37 ' parents: {\n'
38 ' smoke_0.A: smoke_1.B,\n'
39 ' smoke_0.C: smoke_0.A,\n'
40 ' }));\n');
41 });
42
43 test('single mixin', () {
44 var lib = provider.libraryFor('/a.dart');
45 recorder.lookupParent(lib.getType('E'));
46
47 checkResults(generator,
48 imports: ["import '/a.dart' as smoke_0;",],
49 topLevel: 'abstract class _M0 {} // A & D1\n',
50 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
51 ' checkedMode: false,\n'
52 ' parents: {\n'
53 ' smoke_0.E: _M0,\n'
54 ' _M0: smoke_0.A,\n'
55 ' }));\n');
56 });
57
58 test('multiple mixins', () {
59 var lib = provider.libraryFor('/a.dart');
60 recorder.lookupParent(lib.getType('F'));
61
62 checkResults(generator,
63 imports: ["import '/a.dart' as smoke_0;",],
64 topLevel: 'abstract class _M0 {} // A & D1\n'
65 'abstract class _M1 {} // _M0 & D2\n'
66 'abstract class _M2 {} // _M1 & D3\n',
67 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
68 ' checkedMode: false,\n'
69 ' parents: {\n'
70 ' smoke_0.F: _M2,\n'
71 ' _M0: smoke_0.A,\n'
72 ' _M1: _M0,\n'
73 ' _M2: _M1,\n'
74 ' }));\n');
75 });
76
77 test('same as common_test', () {
78 var lib = provider.libraryFor('/common.dart');
79 recorder.lookupParent(lib.getType('Annot'));
80 recorder.lookupParent(lib.getType('AnnotB'));
81 recorder.lookupParent(lib.getType('A'));
82 recorder.lookupParent(lib.getType('B'));
83 recorder.lookupParent(lib.getType('C'));
84 recorder.lookupParent(lib.getType('D'));
85 recorder.lookupParent(lib.getType('E'));
86 recorder.lookupParent(lib.getType('E2'));
87 recorder.lookupParent(lib.getType('F'));
88 recorder.lookupParent(lib.getType('F2'));
89 recorder.lookupParent(lib.getType('G'));
90 recorder.lookupParent(lib.getType('H'));
91 var coreLib =
92 lib.visibleLibraries.firstWhere((l) => l.displayName == 'dart.core');
93 recorder.lookupParent(coreLib.getType('int'));
94 recorder.lookupParent(coreLib.getType('num'));
95
96 checkResults(generator,
97 imports: ["import '/common.dart' as smoke_0;",],
98 topLevel: 'abstract class _M0 {} // C & A\n',
99 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
100 ' checkedMode: false,\n'
101 ' parents: {\n'
102 ' smoke_0.AnnotB: smoke_0.Annot,\n'
103 ' smoke_0.D: _M0,\n'
104 ' smoke_0.E2: smoke_0.E,\n'
105 ' smoke_0.F2: smoke_0.F,\n'
106 ' smoke_0.H: smoke_0.G,\n'
107 ' int: num,\n'
108 ' _M0: smoke_0.C,\n'
109 ' }));\n');
110 });
111 });
112
113 test('add static method, no declaration', () {
114 var lib = provider.libraryFor('/common.dart');
115 recorder.addStaticMethod(lib.getType('A'), 'sM');
116 checkResults(generator,
117 imports: ["import '/common.dart' as smoke_0;",],
118 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
119 ' checkedMode: false,\n'
120 ' staticMethods: {\n'
121 ' smoke_0.A: {\n'
122 ' #sM: smoke_0.A.sM,\n'
123 ' },\n'
124 ' }));\n');
125 });
126
127 group('lookup member', () {
128 var lib;
129 setUp(() {
130 lib = provider.libraryFor('/common.dart');
131 });
132
133 test('missing declaration', () {
134 recorder.lookupMember(lib.getType('A'), 'q', includeAccessors: false);
135 checkResults(generator,
136 imports: ["import '/common.dart' as smoke_0;",],
137 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
138 ' checkedMode: false,\n'
139 ' declarations: {\n'
140 ' smoke_0.A: {},\n'
141 ' }));\n');
142 });
143
144 test('field declaration', () {
145 recorder.lookupMember(lib.getType('A'), 'i', includeAccessors: false);
146 checkResults(generator,
147 imports: ["import '/common.dart' as smoke_0;",],
148 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
149 ' checkedMode: false,\n'
150 ' declarations: {\n'
151 ' smoke_0.A: {\n'
152 ' #i: const Declaration(#i, int),\n'
153 ' },\n'
154 ' }));\n');
155 });
156
157 test('sattic field declaration', () {
158 recorder.lookupMember(lib.getType('A'), 'sI', includeAccessors: false);
159 checkResults(generator,
160 imports: ["import '/common.dart' as smoke_0;",],
161 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
162 ' checkedMode: false,\n'
163 ' declarations: {\n'
164 ' smoke_0.A: {\n'
165 ' #sI: const Declaration(#sI, int, isStatic: true),\n'
166 ' },\n'
167 ' }));\n');
168 });
169
170 test('property declaration', () {
171 recorder.lookupMember(lib.getType('A'), 'j2', includeAccessors: false);
172 checkResults(generator,
173 imports: ["import '/common.dart' as smoke_0;",],
174 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
175 ' checkedMode: false,\n'
176 ' declarations: {\n'
177 ' smoke_0.A: {\n'
178 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n'
179 ' },\n'
180 ' }));\n');
181 });
182
183 test('static property declaration', () {
184 recorder.lookupMember(lib.getType('A'), 'sJ', includeAccessors: false);
185 final details = 'kind: PROPERTY, isFinal: true, isStatic: true';
186 checkResults(generator,
187 imports: ["import '/common.dart' as smoke_0;",],
188 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
189 ' checkedMode: false,\n'
190 ' declarations: {\n'
191 ' smoke_0.A: {\n'
192 ' #sJ: const Declaration(#sJ, int, $details),\n'
193 ' },\n'
194 ' }));\n');
195 });
196
197 test('field and property of dynamic type', () {
198 recorder.lookupMember(lib.getType('I'), 'i1', includeAccessors: false);
199 recorder.lookupMember(lib.getType('I'), 'i2', includeAccessors: false);
200 checkResults(generator,
201 imports: ["import '/common.dart' as smoke_0;",],
202 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
203 ' checkedMode: false,\n'
204 ' declarations: {\n'
205 ' smoke_0.I: {\n'
206 ' #i1: const Declaration(#i1, Object),\n'
207 ' #i2: const Declaration(#i2, Object, kind: PROPERTY),\n'
208 ' },\n'
209 ' }));\n');
210 });
211
212 test('property of concrete type', () {
213 recorder.lookupMember(lib.getType('I'), 'i3', includeAccessors: false);
214 checkResults(generator,
215 imports: ["import '/common.dart' as smoke_0;",],
216 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
217 ' checkedMode: false,\n'
218 ' declarations: {\n'
219 ' smoke_0.I: {\n'
220 ' #i3: const Declaration(#i3, smoke_0.G, kind: PROPERTY, '
221 'isFinal: true),\n'
222 ' },\n'
223 ' }));\n');
224 });
225
226 test('method declaration', () {
227 recorder.lookupMember(lib.getType('A'), 'inc0', includeAccessors: false);
228 checkResults(generator,
229 imports: ["import '/common.dart' as smoke_0;",],
230 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
231 ' checkedMode: false,\n'
232 ' declarations: {\n'
233 ' smoke_0.A: {\n'
234 ' #inc0: const Declaration(#inc0, Function, kind: METHOD),\n'
235 ' },\n'
236 ' }));\n');
237 });
238
239 test('static method declaration', () {
240 recorder.lookupMember(lib.getType('A'), 'sM', includeAccessors: false);
241 const details = 'kind: METHOD, isStatic: true';
242 checkResults(generator,
243 imports: ["import '/common.dart' as smoke_0;",],
244 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
245 ' checkedMode: false,\n'
246 ' declarations: {\n'
247 ' smoke_0.A: {\n'
248 ' #sM: const Declaration(#sM, Function, $details),\n'
249 ' },\n'
250 ' }));\n');
251 });
252
253 test('inherited field - not recursive', () {
254 recorder.lookupMember(lib.getType('D'), 'i', includeAccessors: false);
255 checkResults(generator,
256 imports: ["import '/common.dart' as smoke_0;",],
257 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
258 ' checkedMode: false,\n'
259 ' declarations: {\n'
260 ' smoke_0.D: {},\n'
261 ' }));\n');
262 });
263
264 test('inherited field - recursive', () {
265 recorder.lookupMember(lib.getType('D'), 'i',
266 recursive: true, includeAccessors: false);
267 checkResults(generator,
268 imports: ["import '/common.dart' as smoke_0;",],
269 topLevel: 'abstract class _M0 {} // C & A\n',
270 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
271 ' checkedMode: false,\n'
272 ' parents: {\n'
273 ' smoke_0.D: _M0,\n'
274 ' _M0: smoke_0.C,\n'
275 ' },\n'
276 ' declarations: {\n'
277 ' smoke_0.D: {},\n'
278 ' _M0: {\n'
279 ' #i: const Declaration(#i, int),\n'
280 ' },\n'
281 ' }));\n');
282 });
283
284 test('inherited field - recursive deep', () {
285 recorder.lookupMember(lib.getType('J3'), 'i',
286 recursive: true, includeAccessors: false);
287 checkResults(generator,
288 imports: ["import '/common.dart' as smoke_0;",],
289 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
290 ' checkedMode: false,\n'
291 ' parents: {\n'
292 ' smoke_0.J2: smoke_0.J1,\n'
293 ' smoke_0.J3: smoke_0.J2,\n'
294 ' },\n'
295 ' declarations: {\n'
296 ' smoke_0.J1: {\n'
297 ' #i: const Declaration(#i, int),\n'
298 ' },\n'
299 ' smoke_0.J2: {},\n'
300 ' smoke_0.J3: {},\n'
301 ' }));\n');
302 });
303
304 test('inherited field - recursive - includeUpTo', () {
305 recorder.lookupMember(lib.getType('J3'), 'i',
306 recursive: true,
307 includeAccessors: false,
308 includeUpTo: lib.getType('J1'));
309 checkResults(generator,
310 imports: ["import '/common.dart' as smoke_0;",],
311 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
312 ' checkedMode: false,\n'
313 ' parents: {\n'
314 ' smoke_0.J2: smoke_0.J1,\n'
315 ' smoke_0.J3: smoke_0.J2,\n'
316 ' },\n'
317 ' declarations: {\n'
318 ' smoke_0.J2: {},\n'
319 ' smoke_0.J3: {},\n'
320 ' }));\n');
321 });
322 });
323
324 group('query', () {
325 test('default query', () {
326 var options = new QueryOptions();
327 var lib = provider.libraryFor('/common.dart');
328 recorder.runQuery(lib.getType('A'), options, includeAccessors: false);
329 checkResults(generator,
330 imports: ["import '/common.dart' as smoke_0;",],
331 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
332 ' checkedMode: false,\n'
333 ' declarations: {\n'
334 ' smoke_0.A: {\n'
335 ' #i: const Declaration(#i, int),\n'
336 ' #j: const Declaration(#j, int),\n'
337 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n'
338 ' },\n'
339 ' }));\n');
340 });
341
342 test('only fields', () {
343 var options = new QueryOptions(includeProperties: false);
344 var lib = provider.libraryFor('/common.dart');
345 recorder.runQuery(lib.getType('A'), options, includeAccessors: false);
346 checkResults(generator,
347 imports: ["import '/common.dart' as smoke_0;",],
348 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
349 ' checkedMode: false,\n'
350 ' declarations: {\n'
351 ' smoke_0.A: {\n'
352 ' #i: const Declaration(#i, int),\n'
353 ' #j: const Declaration(#j, int),\n'
354 ' },\n'
355 ' }));\n');
356 });
357
358 test('only properties', () {
359 var options = new QueryOptions(includeFields: false);
360 var lib = provider.libraryFor('/common.dart');
361 recorder.runQuery(lib.getType('A'), options, includeAccessors: false);
362 checkResults(generator,
363 imports: ["import '/common.dart' as smoke_0;",],
364 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
365 ' checkedMode: false,\n'
366 ' declarations: {\n'
367 ' smoke_0.A: {\n'
368 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n'
369 ' },\n'
370 ' }));\n');
371 });
372
373 test('fields, properties, and and methods', () {
374 var options = new QueryOptions(includeMethods: true);
375 var lib = provider.libraryFor('/common.dart');
376 recorder.runQuery(lib.getType('A'), options, includeAccessors: false);
377 checkResults(generator,
378 imports: ["import '/common.dart' as smoke_0;",],
379 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
380 ' checkedMode: false,\n'
381 ' declarations: {\n'
382 ' smoke_0.A: {\n'
383 ' #i: const Declaration(#i, int),\n'
384 ' #inc0: const Declaration(#inc0, Function, kind: METHOD),\n'
385 ' #inc1: const Declaration(#inc1, Function, kind: METHOD),\n'
386 ' #inc2: const Declaration(#inc2, Function, kind: METHOD),\n'
387 ' #j: const Declaration(#j, int),\n'
388 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n'
389 ' },\n'
390 ' }));\n');
391 });
392
393 test('exclude inherited', () {
394 var options = new QueryOptions(includeInherited: false);
395 var lib = provider.libraryFor('/common.dart');
396 recorder.runQuery(lib.getType('D'), options, includeAccessors: false);
397 checkResults(generator,
398 imports: ["import '/common.dart' as smoke_0;",],
399 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
400 ' checkedMode: false,\n'
401 ' declarations: {\n'
402 ' smoke_0.D: {\n'
403 ' #i2: const Declaration(#i2, int, kind: PROPERTY, '
404 'isFinal: true),\n'
405 ' #x2: const Declaration(#x2, int, kind: PROPERTY, '
406 'isFinal: true),\n'
407 ' },\n'
408 ' }));\n');
409 });
410
411 test('include inherited', () {
412 var options = new QueryOptions(includeInherited: true);
413 var lib = provider.libraryFor('/common.dart');
414 recorder.runQuery(lib.getType('D'), options, includeAccessors: false);
415 checkResults(generator,
416 imports: ["import '/common.dart' as smoke_0;",],
417 topLevel: 'abstract class _M0 {} // C & A\n',
418 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
419 ' checkedMode: false,\n'
420 ' parents: {\n'
421 ' smoke_0.D: _M0,\n'
422 ' _M0: smoke_0.C,\n'
423 ' },\n'
424 ' declarations: {\n'
425 ' smoke_0.C: {\n'
426 ' #b: const Declaration(#b, smoke_0.B),\n'
427 ' #x: const Declaration(#x, int),\n'
428 ' #y: const Declaration(#y, String),\n'
429 ' },\n'
430 ' smoke_0.D: {\n'
431 ' #i2: const Declaration(#i2, int, kind: PROPERTY, '
432 'isFinal: true),\n'
433 ' #x2: const Declaration(#x2, int, kind: PROPERTY, '
434 'isFinal: true),\n'
435 ' },\n'
436 ' _M0: {\n'
437 ' #i: const Declaration(#i, int),\n'
438 ' #j: const Declaration(#j, int),\n'
439 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n'
440 ' },\n'
441 ' }));\n');
442 });
443
444 test('exact annotation', () {
445 var lib = provider.libraryFor('/common.dart');
446 var vars = lib.definingCompilationUnit.topLevelVariables;
447 expect(vars[0].name, 'a1');
448 var options =
449 new QueryOptions(includeInherited: true, withAnnotations: [vars[0]]);
450 recorder.runQuery(lib.getType('H'), options, includeAccessors: false);
451 final annot = 'annotations: const [smoke_0.a1]';
452 checkResults(generator,
453 imports: ["import '/common.dart' as smoke_0;",],
454 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
455 ' checkedMode: false,\n'
456 ' parents: {\n'
457 ' smoke_0.H: smoke_0.G,\n'
458 ' },\n'
459 ' declarations: {\n'
460 ' smoke_0.G: {\n'
461 ' #b: const Declaration(#b, int, $annot),\n'
462 ' },\n'
463 ' smoke_0.H: {\n'
464 ' #f: const Declaration(#f, int, $annot),\n'
465 ' #g: const Declaration(#g, int, $annot),\n'
466 ' },\n'
467 ' }));\n');
468 });
469
470 test('type annotation', () {
471 var lib = provider.libraryFor('/common.dart');
472 var options = new QueryOptions(
473 includeInherited: true, withAnnotations: [lib.getType('Annot')]);
474 recorder.runQuery(lib.getType('H'), options, includeAccessors: false);
475 final a1Annot = 'annotations: const [smoke_0.a1]';
476 final a3Annot = 'annotations: const [smoke_0.a3]';
477 final exprAnnot = 'annotations: const [const smoke_0.Annot(1)]';
478 checkResults(generator,
479 imports: ["import '/common.dart' as smoke_0;",],
480 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
481 ' checkedMode: false,\n'
482 ' parents: {\n'
483 ' smoke_0.H: smoke_0.G,\n'
484 ' },\n'
485 ' declarations: {\n'
486 ' smoke_0.G: {\n'
487 ' #b: const Declaration(#b, int, $a1Annot),\n'
488 ' },\n'
489 ' smoke_0.H: {\n'
490 ' #f: const Declaration(#f, int, $a1Annot),\n'
491 ' #g: const Declaration(#g, int, $a1Annot),\n'
492 ' #i: const Declaration(#i, int, $a3Annot),\n'
493 ' #j: const Declaration(#j, int, $exprAnnot),\n'
494 ' },\n'
495 ' }));\n');
496 });
497
498 test('type annotation with named arguments', () {
499 var lib = provider.libraryFor('/common.dart');
500 var options = new QueryOptions(
501 includeInherited: true, withAnnotations: [lib.getType('AnnotC')]);
502 recorder.runQuery(lib.getType('K'), options, includeAccessors: false);
503 final kAnnot = 'annotations: const [const smoke_0.AnnotC(named: true)]';
504 final k2Annot = 'annotations: const [const smoke_0.AnnotC()]';
505 checkResults(generator,
506 imports: ["import '/common.dart' as smoke_0;",],
507 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
508 ' checkedMode: false,\n'
509 ' declarations: {\n'
510 ' smoke_0.K: {\n'
511 ' #k: const Declaration(#k, int, $kAnnot),\n'
512 ' #k2: const Declaration(#k2, int, $k2Annot),\n'
513 ' },\n'
514 ' }));\n');
515 });
516 });
517
518 group('with accessors', () {
519 test('lookup member', () {
520 var lib = provider.libraryFor('/common.dart');
521 recorder.lookupMember(lib.getType('I'), 'i1');
522 recorder.lookupMember(lib.getType('I'), 'i2');
523 recorder.lookupMember(lib.getType('I'), 'i3');
524 recorder.lookupMember(lib.getType('I'), 'm4');
525 checkResults(generator,
526 imports: ["import '/common.dart' as smoke_0;",],
527 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
528 ' checkedMode: false,\n'
529 ' getters: {\n'
530 ' #i1: (o) => o.i1,\n'
531 ' #i2: (o) => o.i2,\n'
532 ' #i3: (o) => o.i3,\n'
533 ' #m4: (o) => o.m4,\n'
534 ' },\n'
535 ' setters: {\n' // #i3 is final
536 ' #i1: (o, v) { o.i1 = v; },\n'
537 ' #i2: (o, v) { o.i2 = v; },\n'
538 ' },\n'
539 ' declarations: {\n'
540 ' smoke_0.I: {\n'
541 ' #i1: const Declaration(#i1, Object),\n'
542 ' #i2: const Declaration(#i2, Object, kind: PROPERTY),\n'
543 ' #i3: const Declaration(#i3, smoke_0.G, kind: PROPERTY, '
544 'isFinal: true),\n'
545 ' #m4: const Declaration(#m4, Function, kind: METHOD),\n'
546 ' },\n'
547 ' },\n'
548 ' names: {\n'
549 ' #i1: r\'i1\',\n'
550 ' #i2: r\'i2\',\n'
551 ' #i3: r\'i3\',\n'
552 ' #m4: r\'m4\',\n'
553 ' }));\n');
554 });
555
556 test('static members', () {
557 var lib = provider.libraryFor('/common.dart');
558 recorder.lookupMember(lib.getType('A'), 'sI');
559 recorder.lookupMember(lib.getType('A'), 'sJ');
560 recorder.lookupMember(lib.getType('A'), 'sM');
561 final pDetails = 'kind: PROPERTY, isFinal: true, isStatic: true';
562 const mDetails = 'kind: METHOD, isStatic: true';
563 checkResults(generator,
564 imports: ["import '/common.dart' as smoke_0;",],
565 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
566 ' checkedMode: false,\n'
567 ' declarations: {\n'
568 ' smoke_0.A: {\n'
569 ' #sI: const Declaration(#sI, int, isStatic: true),\n'
570 ' #sJ: const Declaration(#sJ, int, $pDetails),\n'
571 ' #sM: const Declaration(#sM, Function, $mDetails),\n'
572 ' },\n'
573 ' },\n'
574 ' staticMethods: {\n'
575 ' smoke_0.A: {\n'
576 ' #sM: smoke_0.A.sM,\n'
577 ' },\n'
578 ' },\n'
579 ' names: {\n'
580 ' #sM: r\'sM\',\n'
581 ' }));\n');
582 });
583
584 test('query', () {
585 var lib = provider.libraryFor('/common.dart');
586 var options = new QueryOptions(
587 includeInherited: true, withAnnotations: [lib.getType('Annot')]);
588 recorder.runQuery(lib.getType('H'), options);
589 final a1Annot = 'annotations: const [smoke_0.a1]';
590 final a3Annot = 'annotations: const [smoke_0.a3]';
591 final exprAnnot = 'annotations: const [const smoke_0.Annot(1)]';
592 checkResults(generator,
593 imports: ["import '/common.dart' as smoke_0;",],
594 initCall: 'useGeneratedCode(new StaticConfiguration(\n'
595 ' checkedMode: false,\n'
596 ' getters: {\n'
597 ' #b: (o) => o.b,\n'
598 ' #f: (o) => o.f,\n'
599 ' #g: (o) => o.g,\n'
600 ' #i: (o) => o.i,\n'
601 ' #j: (o) => o.j,\n'
602 ' },\n'
603 ' setters: {\n' // #i3 is final
604 ' #b: (o, v) { o.b = v; },\n'
605 ' #f: (o, v) { o.f = v; },\n'
606 ' #g: (o, v) { o.g = v; },\n'
607 ' #i: (o, v) { o.i = v; },\n'
608 ' #j: (o, v) { o.j = v; },\n'
609 ' },\n'
610 ' parents: {\n'
611 ' smoke_0.H: smoke_0.G,\n'
612 ' },\n'
613 ' declarations: {\n'
614 ' smoke_0.G: {\n'
615 ' #b: const Declaration(#b, int, $a1Annot),\n'
616 ' },\n'
617 ' smoke_0.H: {\n'
618 ' #f: const Declaration(#f, int, $a1Annot),\n'
619 ' #g: const Declaration(#g, int, $a1Annot),\n'
620 ' #i: const Declaration(#i, int, $a3Annot),\n'
621 ' #j: const Declaration(#j, int, $exprAnnot),\n'
622 ' },\n'
623 ' },\n'
624 ' names: {\n'
625 ' #b: r\'b\',\n'
626 ' #f: r\'f\',\n'
627 ' #g: r\'g\',\n'
628 ' #i: r\'i\',\n'
629 ' #j: r\'j\',\n'
630 ' }));\n');
631 });
632 });
633 }
634
635 const _SOURCES = const {
636 '/a.dart': '''
637 library a;
638 import '/b.dart';
639
640 class Annot { const Annot(); }
641 const annot = const Annot();
642
643 class A extends B {}
644 class C extends A {}
645 class D1 {
646 int d1;
647 }
648 class D2 {
649 int d2;
650 }
651 class D3 {
652 int d3;
653 }
654 class E extends A with D1 {
655 int e1;
656 }
657 class F extends A with D1, D2, D3 {
658 int f1;
659 }
660 ''',
661 '/b.dart': '''
662 library b;
663
664 class B {}
665 ''',
666 '/common.dart': '''
667 library common;
668
669 class A {
670 int i = 42;
671 int j = 44;
672 int get j2 => j;
673 void set j2(int v) { j = v; }
674 void inc0() { i++; }
675 void inc1(int v) { i = i + (v == null ? -10 : v); }
676 void inc2([int v]) { i = i + (v == null ? -10 : v); }
677 static int sI;
678 static int get sJ => 0;
679 static void sM() {}
680 }
681
682 class B {
683 final int f = 3;
684 int _w;
685 int get w => _w;
686 set w(int v) { _w = v; }
687
688 String z;
689 A a;
690
691 B(this._w, this.z, this.a);
692 }
693
694 class C {
695 int x;
696 String y;
697 B b;
698
699 inc(int n) {
700 x = x + n;
701 }
702 dec(int n) {
703 x = x - n;
704 }
705
706 C(this.x, this.y, this.b);
707 }
708
709
710 class D extends C with A {
711 int get x2 => x;
712 int get i2 => i;
713
714 D(x, y, b) : super(x, y, b);
715 }
716
717 class E {
718 set x(int v) { }
719 int get y => 1;
720
721 noSuchMethod(i) => y;
722 }
723
724 class E2 extends E {}
725
726 class F {
727 static int staticMethod(A a) => a.i;
728 }
729
730 class F2 extends F {}
731
732 class Annot { const Annot(int ignore); }
733 class AnnotB extends Annot { const AnnotB(); }
734 class AnnotC { const AnnotC({bool named: false}); }
735 const a1 = const Annot(0);
736 const a2 = 32;
737 const a3 = const AnnotB();
738
739
740 class G {
741 int a;
742 @a1 int b;
743 int c;
744 @a2 int d;
745 }
746
747 class H extends G {
748 int e;
749 @a1 int f;
750 @a1 int g;
751 @a2 int h;
752 @a3 int i;
753 @Annot(1) int j;
754 }
755
756 class I {
757 dynamic i1;
758 get i2 => null;
759 set i2(v) {}
760 G get i3;
761 G m4() {};
762 }
763
764 class J1 {
765 int i;
766 }
767 class J2 extends J1 {
768 }
769 class J3 extends J2 {
770 }
771
772 class K {
773 @AnnotC(named: true) int k;
774 @AnnotC() int k2;
775 }
776 '''
777 };
778
779 resolveImportUrl(LibraryElement lib) =>
780 lib.isDartCore ? 'dart:core' : '/${lib.displayName}.dart';
OLDNEW
« no previous file with comments | « packages/smoke/test/codegen/generator_test.dart ('k') | packages/smoke/test/codegen/testing_resolver_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698