OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 smoke.test.codegen.recorder_test; | 5 library smoke.test.codegen.recorder_test; |
6 | 6 |
7 import 'package:analyzer/src/generated/element.dart'; | 7 import 'package:analyzer/src/generated/element.dart'; |
8 import 'package:smoke/codegen/generator.dart'; | 8 import 'package:smoke/codegen/generator.dart'; |
9 import 'package:smoke/codegen/recorder.dart'; | 9 import 'package:smoke/codegen/recorder.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 }); | 122 }); |
123 }); | 123 }); |
124 | 124 |
125 group('lookup member', () { | 125 group('lookup member', () { |
126 var lib; | 126 var lib; |
127 setUp(() { | 127 setUp(() { |
128 lib = provider.libraryFor('/common.dart'); | 128 lib = provider.libraryFor('/common.dart'); |
129 }); | 129 }); |
130 | 130 |
131 test('missing declaration', () { | 131 test('missing declaration', () { |
132 recorder.lookupMember(lib.getType('A'), 'q'); | 132 recorder.lookupMember(lib.getType('A'), 'q', includeAccessors: false); |
133 checkResults(generator, | 133 checkResults(generator, |
134 imports: [ | 134 imports: [ |
135 "import '/common.dart' as smoke_0;", | 135 "import '/common.dart' as smoke_0;", |
136 ], | 136 ], |
137 initCall: | 137 initCall: |
138 'useGeneratedCode(new StaticConfiguration(\n' | 138 'useGeneratedCode(new StaticConfiguration(\n' |
139 ' checkedMode: false,\n' | 139 ' checkedMode: false,\n' |
140 ' declarations: {\n' | 140 ' declarations: {\n' |
141 ' smoke_0.A: const {},\n' | 141 ' smoke_0.A: const {},\n' |
142 ' }));\n'); | 142 ' }));\n'); |
143 }); | 143 }); |
144 | 144 |
145 test('field declaration', () { | 145 test('field declaration', () { |
146 recorder.lookupMember(lib.getType('A'), 'i'); | 146 recorder.lookupMember(lib.getType('A'), 'i', includeAccessors: false); |
147 checkResults(generator, | 147 checkResults(generator, |
148 imports: [ | 148 imports: [ |
149 "import '/common.dart' as smoke_0;", | 149 "import '/common.dart' as smoke_0;", |
150 ], | 150 ], |
151 initCall: | 151 initCall: |
152 'useGeneratedCode(new StaticConfiguration(\n' | 152 'useGeneratedCode(new StaticConfiguration(\n' |
153 ' checkedMode: false,\n' | 153 ' checkedMode: false,\n' |
154 ' declarations: {\n' | 154 ' declarations: {\n' |
155 ' smoke_0.A: {\n' | 155 ' smoke_0.A: {\n' |
156 ' #i: const Declaration(#i, int),\n' | 156 ' #i: const Declaration(#i, int),\n' |
157 ' },\n' | 157 ' },\n' |
158 ' }));\n'); | 158 ' }));\n'); |
159 }); | 159 }); |
160 | 160 |
161 test('property declaration', () { | 161 test('property declaration', () { |
162 recorder.lookupMember(lib.getType('A'), 'j2'); | 162 recorder.lookupMember(lib.getType('A'), 'j2', includeAccessors: false); |
163 checkResults(generator, | 163 checkResults(generator, |
164 imports: [ | 164 imports: [ |
165 "import '/common.dart' as smoke_0;", | 165 "import '/common.dart' as smoke_0;", |
166 ], | 166 ], |
167 initCall: | 167 initCall: |
168 'useGeneratedCode(new StaticConfiguration(\n' | 168 'useGeneratedCode(new StaticConfiguration(\n' |
169 ' checkedMode: false,\n' | 169 ' checkedMode: false,\n' |
170 ' declarations: {\n' | 170 ' declarations: {\n' |
171 ' smoke_0.A: {\n' | 171 ' smoke_0.A: {\n' |
172 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' | 172 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' |
173 ' },\n' | 173 ' },\n' |
174 ' }));\n'); | 174 ' }));\n'); |
175 }); | 175 }); |
176 | 176 |
| 177 test('field and property of dynamic type', () { |
| 178 recorder.lookupMember(lib.getType('I'), 'i1', includeAccessors: false); |
| 179 recorder.lookupMember(lib.getType('I'), 'i2', includeAccessors: false); |
| 180 checkResults(generator, |
| 181 imports: [ |
| 182 "import '/common.dart' as smoke_0;", |
| 183 ], |
| 184 initCall: |
| 185 'useGeneratedCode(new StaticConfiguration(\n' |
| 186 ' checkedMode: false,\n' |
| 187 ' declarations: {\n' |
| 188 ' smoke_0.I: {\n' |
| 189 ' #i1: const Declaration(#i1, dynamic),\n' |
| 190 ' #i2: const Declaration(#i2, dynamic, kind: PROPERTY),\n' |
| 191 ' },\n' |
| 192 ' }));\n'); |
| 193 }); |
| 194 |
| 195 test('property of concrete type', () { |
| 196 recorder.lookupMember(lib.getType('I'), 'i3', includeAccessors: false); |
| 197 checkResults(generator, |
| 198 imports: [ |
| 199 "import '/common.dart' as smoke_0;", |
| 200 ], |
| 201 initCall: |
| 202 'useGeneratedCode(new StaticConfiguration(\n' |
| 203 ' checkedMode: false,\n' |
| 204 ' declarations: {\n' |
| 205 ' smoke_0.I: {\n' |
| 206 ' #i3: const Declaration(#i3, smoke_0.G, kind: PROPERTY, ' |
| 207 'isFinal: true),\n' |
| 208 ' },\n' |
| 209 ' }));\n'); |
| 210 }); |
| 211 |
177 test('method declaration', () { | 212 test('method declaration', () { |
178 recorder.lookupMember(lib.getType('A'), 'inc0'); | 213 recorder.lookupMember(lib.getType('A'), 'inc0', includeAccessors: false); |
179 checkResults(generator, | 214 checkResults(generator, |
180 imports: [ | 215 imports: [ |
181 "import '/common.dart' as smoke_0;", | 216 "import '/common.dart' as smoke_0;", |
182 ], | 217 ], |
183 initCall: | 218 initCall: |
184 'useGeneratedCode(new StaticConfiguration(\n' | 219 'useGeneratedCode(new StaticConfiguration(\n' |
185 ' checkedMode: false,\n' | 220 ' checkedMode: false,\n' |
186 ' declarations: {\n' | 221 ' declarations: {\n' |
187 ' smoke_0.A: {\n' | 222 ' smoke_0.A: {\n' |
188 ' #inc0: const Declaration(#inc0, Function, kind: METHOD),\n' | 223 ' #inc0: const Declaration(#inc0, Function, kind: METHOD),\n' |
189 ' },\n' | 224 ' },\n' |
190 ' }));\n'); | 225 ' }));\n'); |
191 }); | 226 }); |
192 | 227 |
193 test('inherited field - not recursive', () { | 228 test('inherited field - not recursive', () { |
194 recorder.lookupMember(lib.getType('D'), 'i'); | 229 recorder.lookupMember(lib.getType('D'), 'i', includeAccessors: false); |
195 checkResults(generator, | 230 checkResults(generator, |
196 imports: [ | 231 imports: [ |
197 "import '/common.dart' as smoke_0;", | 232 "import '/common.dart' as smoke_0;", |
198 ], | 233 ], |
199 initCall: | 234 initCall: |
200 'useGeneratedCode(new StaticConfiguration(\n' | 235 'useGeneratedCode(new StaticConfiguration(\n' |
201 ' checkedMode: false,\n' | 236 ' checkedMode: false,\n' |
202 ' declarations: {\n' | 237 ' declarations: {\n' |
203 ' smoke_0.D: const {},\n' | 238 ' smoke_0.D: const {},\n' |
204 ' }));\n'); | 239 ' }));\n'); |
205 }); | 240 }); |
206 | 241 |
207 test('inherited field - recursive', () { | 242 test('inherited field - recursive', () { |
208 recorder.lookupMember(lib.getType('D'), 'i', recursive: true); | 243 recorder.lookupMember(lib.getType('D'), 'i', recursive: true, |
| 244 includeAccessors: false); |
209 checkResults(generator, | 245 checkResults(generator, |
210 imports: [ | 246 imports: [ |
211 "import '/common.dart' as smoke_0;", | 247 "import '/common.dart' as smoke_0;", |
212 ], | 248 ], |
213 topLevel: 'abstract class _M0 {} // C & A\n', | 249 topLevel: 'abstract class _M0 {} // C & A\n', |
214 initCall: | 250 initCall: |
215 'useGeneratedCode(new StaticConfiguration(\n' | 251 'useGeneratedCode(new StaticConfiguration(\n' |
216 ' checkedMode: false,\n' | 252 ' checkedMode: false,\n' |
217 ' parents: {\n' | 253 ' parents: {\n' |
218 ' smoke_0.D: _M0,\n' | 254 ' smoke_0.D: _M0,\n' |
219 ' _M0: smoke_0.C,\n' | 255 ' _M0: smoke_0.C,\n' |
220 ' },\n' | 256 ' },\n' |
221 ' declarations: {\n' | 257 ' declarations: {\n' |
222 ' smoke_0.D: const {},\n' | 258 ' smoke_0.D: const {},\n' |
223 ' _M0: {\n' | 259 ' _M0: {\n' |
224 ' #i: const Declaration(#i, int),\n' | 260 ' #i: const Declaration(#i, int),\n' |
225 ' },\n' | 261 ' },\n' |
226 ' }));\n'); | 262 ' }));\n'); |
227 }); | 263 }); |
228 }); | 264 }); |
229 | 265 |
230 group('query', () { | 266 group('query', () { |
231 test('default query', () { | 267 test('default query', () { |
232 var options = new QueryOptions(); | 268 var options = new QueryOptions(); |
233 var lib = provider.libraryFor('/common.dart'); | 269 var lib = provider.libraryFor('/common.dart'); |
234 recorder.runQuery(lib.getType('A'), options); | 270 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); |
235 checkResults(generator, | 271 checkResults(generator, |
236 imports: [ | 272 imports: [ |
237 "import '/common.dart' as smoke_0;", | 273 "import '/common.dart' as smoke_0;", |
238 ], | 274 ], |
239 initCall: | 275 initCall: |
240 'useGeneratedCode(new StaticConfiguration(\n' | 276 'useGeneratedCode(new StaticConfiguration(\n' |
241 ' checkedMode: false,\n' | 277 ' checkedMode: false,\n' |
242 ' declarations: {\n' | 278 ' declarations: {\n' |
243 ' smoke_0.A: {\n' | 279 ' smoke_0.A: {\n' |
244 ' #i: const Declaration(#i, int),\n' | 280 ' #i: const Declaration(#i, int),\n' |
245 ' #j: const Declaration(#j, int),\n' | 281 ' #j: const Declaration(#j, int),\n' |
246 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' | 282 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' |
247 ' },\n' | 283 ' },\n' |
248 ' }));\n'); | 284 ' }));\n'); |
249 | 285 |
250 }); | 286 }); |
251 | 287 |
252 test('only fields', () { | 288 test('only fields', () { |
253 var options = new QueryOptions(includeProperties: false); | 289 var options = new QueryOptions(includeProperties: false); |
254 var lib = provider.libraryFor('/common.dart'); | 290 var lib = provider.libraryFor('/common.dart'); |
255 recorder.runQuery(lib.getType('A'), options); | 291 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); |
256 checkResults(generator, | 292 checkResults(generator, |
257 imports: [ | 293 imports: [ |
258 "import '/common.dart' as smoke_0;", | 294 "import '/common.dart' as smoke_0;", |
259 ], | 295 ], |
260 initCall: | 296 initCall: |
261 'useGeneratedCode(new StaticConfiguration(\n' | 297 'useGeneratedCode(new StaticConfiguration(\n' |
262 ' checkedMode: false,\n' | 298 ' checkedMode: false,\n' |
263 ' declarations: {\n' | 299 ' declarations: {\n' |
264 ' smoke_0.A: {\n' | 300 ' smoke_0.A: {\n' |
265 ' #i: const Declaration(#i, int),\n' | 301 ' #i: const Declaration(#i, int),\n' |
266 ' #j: const Declaration(#j, int),\n' | 302 ' #j: const Declaration(#j, int),\n' |
267 ' },\n' | 303 ' },\n' |
268 ' }));\n'); | 304 ' }));\n'); |
269 | 305 |
270 }); | 306 }); |
271 | 307 |
272 test('only properties', () { | 308 test('only properties', () { |
273 var options = new QueryOptions(includeFields: false); | 309 var options = new QueryOptions(includeFields: false); |
274 var lib = provider.libraryFor('/common.dart'); | 310 var lib = provider.libraryFor('/common.dart'); |
275 recorder.runQuery(lib.getType('A'), options); | 311 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); |
276 checkResults(generator, | 312 checkResults(generator, |
277 imports: [ | 313 imports: [ |
278 "import '/common.dart' as smoke_0;", | 314 "import '/common.dart' as smoke_0;", |
279 ], | 315 ], |
280 initCall: | 316 initCall: |
281 'useGeneratedCode(new StaticConfiguration(\n' | 317 'useGeneratedCode(new StaticConfiguration(\n' |
282 ' checkedMode: false,\n' | 318 ' checkedMode: false,\n' |
283 ' declarations: {\n' | 319 ' declarations: {\n' |
284 ' smoke_0.A: {\n' | 320 ' smoke_0.A: {\n' |
285 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' | 321 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' |
286 ' },\n' | 322 ' },\n' |
287 ' }));\n'); | 323 ' }));\n'); |
288 | 324 |
289 }); | 325 }); |
290 | 326 |
291 test('fields, properties, and and methods', () { | 327 test('fields, properties, and and methods', () { |
292 var options = new QueryOptions(includeMethods: true); | 328 var options = new QueryOptions(includeMethods: true); |
293 var lib = provider.libraryFor('/common.dart'); | 329 var lib = provider.libraryFor('/common.dart'); |
294 recorder.runQuery(lib.getType('A'), options); | 330 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); |
295 checkResults(generator, | 331 checkResults(generator, |
296 imports: [ | 332 imports: [ |
297 "import '/common.dart' as smoke_0;", | 333 "import '/common.dart' as smoke_0;", |
298 ], | 334 ], |
299 initCall: | 335 initCall: |
300 'useGeneratedCode(new StaticConfiguration(\n' | 336 'useGeneratedCode(new StaticConfiguration(\n' |
301 ' checkedMode: false,\n' | 337 ' checkedMode: false,\n' |
302 ' declarations: {\n' | 338 ' declarations: {\n' |
303 ' smoke_0.A: {\n' | 339 ' smoke_0.A: {\n' |
304 ' #i: const Declaration(#i, int),\n' | 340 ' #i: const Declaration(#i, int),\n' |
305 ' #inc0: const Declaration(#inc0, Function, kind: METHOD),\n' | 341 ' #inc0: const Declaration(#inc0, Function, kind: METHOD),\n' |
306 ' #inc1: const Declaration(#inc1, Function, kind: METHOD),\n' | 342 ' #inc1: const Declaration(#inc1, Function, kind: METHOD),\n' |
307 ' #inc2: const Declaration(#inc2, Function, kind: METHOD),\n' | 343 ' #inc2: const Declaration(#inc2, Function, kind: METHOD),\n' |
308 ' #j: const Declaration(#j, int),\n' | 344 ' #j: const Declaration(#j, int),\n' |
309 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' | 345 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' |
310 ' },\n' | 346 ' },\n' |
311 ' }));\n'); | 347 ' }));\n'); |
312 }); | 348 }); |
313 | 349 |
314 test('exclude inherited', () { | 350 test('exclude inherited', () { |
315 var options = new QueryOptions(includeInherited: false); | 351 var options = new QueryOptions(includeInherited: false); |
316 var lib = provider.libraryFor('/common.dart'); | 352 var lib = provider.libraryFor('/common.dart'); |
317 recorder.runQuery(lib.getType('D'), options); | 353 recorder.runQuery(lib.getType('D'), options, includeAccessors: false); |
318 checkResults(generator, | 354 checkResults(generator, |
319 imports: [ | 355 imports: [ |
320 "import '/common.dart' as smoke_0;", | 356 "import '/common.dart' as smoke_0;", |
321 ], | 357 ], |
322 initCall: | 358 initCall: |
323 'useGeneratedCode(new StaticConfiguration(\n' | 359 'useGeneratedCode(new StaticConfiguration(\n' |
324 ' checkedMode: false,\n' | 360 ' checkedMode: false,\n' |
325 ' declarations: {\n' | 361 ' declarations: {\n' |
326 ' smoke_0.D: {\n' | 362 ' smoke_0.D: {\n' |
327 ' #i2: const Declaration(#i2, int, kind: PROPERTY, ' | 363 ' #i2: const Declaration(#i2, int, kind: PROPERTY, ' |
328 'isFinal: true),\n' | 364 'isFinal: true),\n' |
329 ' #x2: const Declaration(#x2, int, kind: PROPERTY, ' | 365 ' #x2: const Declaration(#x2, int, kind: PROPERTY, ' |
330 'isFinal: true),\n' | 366 'isFinal: true),\n' |
331 ' },\n' | 367 ' },\n' |
332 ' }));\n'); | 368 ' }));\n'); |
333 }); | 369 }); |
334 | 370 |
335 test('include inherited', () { | 371 test('include inherited', () { |
336 var options = new QueryOptions(includeInherited: true); | 372 var options = new QueryOptions(includeInherited: true); |
337 var lib = provider.libraryFor('/common.dart'); | 373 var lib = provider.libraryFor('/common.dart'); |
338 recorder.runQuery(lib.getType('D'), options); | 374 recorder.runQuery(lib.getType('D'), options, includeAccessors: false); |
339 checkResults(generator, | 375 checkResults(generator, |
340 imports: [ | 376 imports: [ |
341 "import '/common.dart' as smoke_0;", | 377 "import '/common.dart' as smoke_0;", |
342 ], | 378 ], |
343 topLevel: 'abstract class _M0 {} // C & A\n', | 379 topLevel: 'abstract class _M0 {} // C & A\n', |
344 initCall: | 380 initCall: |
345 'useGeneratedCode(new StaticConfiguration(\n' | 381 'useGeneratedCode(new StaticConfiguration(\n' |
346 ' checkedMode: false,\n' | 382 ' checkedMode: false,\n' |
347 ' parents: {\n' | 383 ' parents: {\n' |
348 ' smoke_0.D: _M0,\n' | 384 ' smoke_0.D: _M0,\n' |
(...skipping 18 matching lines...) Expand all Loading... |
367 ' },\n' | 403 ' },\n' |
368 ' }));\n'); | 404 ' }));\n'); |
369 }); | 405 }); |
370 | 406 |
371 test('exact annotation', () { | 407 test('exact annotation', () { |
372 var lib = provider.libraryFor('/common.dart'); | 408 var lib = provider.libraryFor('/common.dart'); |
373 var vars = lib.definingCompilationUnit.topLevelVariables; | 409 var vars = lib.definingCompilationUnit.topLevelVariables; |
374 expect(vars[0].name, 'a1'); | 410 expect(vars[0].name, 'a1'); |
375 var options = new QueryOptions(includeInherited: true, | 411 var options = new QueryOptions(includeInherited: true, |
376 withAnnotations: [vars[0]]); | 412 withAnnotations: [vars[0]]); |
377 recorder.runQuery(lib.getType('H'), options); | 413 recorder.runQuery(lib.getType('H'), options, includeAccessors: false); |
378 final annot = 'annotations: const [smoke_0.a1]'; | 414 final annot = 'annotations: const [smoke_0.a1]'; |
379 checkResults(generator, | 415 checkResults(generator, |
380 imports: [ | 416 imports: [ |
381 "import '/common.dart' as smoke_0;", | 417 "import '/common.dart' as smoke_0;", |
382 ], | 418 ], |
383 initCall: | 419 initCall: |
384 'useGeneratedCode(new StaticConfiguration(\n' | 420 'useGeneratedCode(new StaticConfiguration(\n' |
385 ' checkedMode: false,\n' | 421 ' checkedMode: false,\n' |
386 ' parents: {\n' | 422 ' parents: {\n' |
387 ' smoke_0.H: smoke_0.G,\n' | 423 ' smoke_0.H: smoke_0.G,\n' |
388 ' },\n' | 424 ' },\n' |
389 ' declarations: {\n' | 425 ' declarations: {\n' |
390 ' smoke_0.G: {\n' | 426 ' smoke_0.G: {\n' |
391 ' #b: const Declaration(#b, int, $annot),\n' | 427 ' #b: const Declaration(#b, int, $annot),\n' |
392 ' },\n' | 428 ' },\n' |
393 ' smoke_0.H: {\n' | 429 ' smoke_0.H: {\n' |
394 ' #f: const Declaration(#f, int, $annot),\n' | 430 ' #f: const Declaration(#f, int, $annot),\n' |
395 ' #g: const Declaration(#g, int, $annot),\n' | 431 ' #g: const Declaration(#g, int, $annot),\n' |
396 ' },\n' | 432 ' },\n' |
397 ' }));\n'); | 433 ' }));\n'); |
398 }); | 434 }); |
399 | 435 |
400 test('type annotation', () { | 436 test('type annotation', () { |
401 var lib = provider.libraryFor('/common.dart'); | 437 var lib = provider.libraryFor('/common.dart'); |
402 var options = new QueryOptions(includeInherited: true, | 438 var options = new QueryOptions(includeInherited: true, |
403 withAnnotations: [lib.getType('Annot')]); | 439 withAnnotations: [lib.getType('Annot')]); |
| 440 recorder.runQuery(lib.getType('H'), options, includeAccessors: false); |
| 441 final a1Annot = 'annotations: const [smoke_0.a1]'; |
| 442 final a3Annot = 'annotations: const [smoke_0.a3]'; |
| 443 final exprAnnot = 'annotations: const [const smoke_0.Annot(1)]'; |
| 444 checkResults(generator, |
| 445 imports: [ |
| 446 "import '/common.dart' as smoke_0;", |
| 447 ], |
| 448 initCall: |
| 449 'useGeneratedCode(new StaticConfiguration(\n' |
| 450 ' checkedMode: false,\n' |
| 451 ' parents: {\n' |
| 452 ' smoke_0.H: smoke_0.G,\n' |
| 453 ' },\n' |
| 454 ' declarations: {\n' |
| 455 ' smoke_0.G: {\n' |
| 456 ' #b: const Declaration(#b, int, $a1Annot),\n' |
| 457 ' },\n' |
| 458 ' smoke_0.H: {\n' |
| 459 ' #f: const Declaration(#f, int, $a1Annot),\n' |
| 460 ' #g: const Declaration(#g, int, $a1Annot),\n' |
| 461 ' #i: const Declaration(#i, int, $a3Annot),\n' |
| 462 ' #j: const Declaration(#j, int, $exprAnnot),\n' |
| 463 ' },\n' |
| 464 ' }));\n'); |
| 465 }); |
| 466 }); |
| 467 |
| 468 group('with accessors', () { |
| 469 test('lookup member', () { |
| 470 var lib = provider.libraryFor('/common.dart'); |
| 471 recorder.lookupMember(lib.getType('I'), 'i1'); |
| 472 recorder.lookupMember(lib.getType('I'), 'i2'); |
| 473 recorder.lookupMember(lib.getType('I'), 'i3'); |
| 474 checkResults(generator, |
| 475 imports: [ |
| 476 "import '/common.dart' as smoke_0;", |
| 477 ], |
| 478 initCall: |
| 479 'useGeneratedCode(new StaticConfiguration(\n' |
| 480 ' checkedMode: false,\n' |
| 481 ' getters: {\n' |
| 482 ' #i1: (o) => o.i1,\n' |
| 483 ' #i2: (o) => o.i2,\n' |
| 484 ' #i3: (o) => o.i3,\n' |
| 485 ' },\n' |
| 486 ' setters: {\n' // #i3 is final |
| 487 ' #i1: (o, v) { o.i1 = v; },\n' |
| 488 ' #i2: (o, v) { o.i2 = v; },\n' |
| 489 ' },\n' |
| 490 ' declarations: {\n' |
| 491 ' smoke_0.I: {\n' |
| 492 ' #i1: const Declaration(#i1, dynamic),\n' |
| 493 ' #i2: const Declaration(#i2, dynamic, kind: PROPERTY),\n' |
| 494 ' #i3: const Declaration(#i3, smoke_0.G, kind: PROPERTY, ' |
| 495 'isFinal: true),\n' |
| 496 ' },\n' |
| 497 ' },\n' |
| 498 ' names: {\n' |
| 499 ' #i1: \'i1\',\n' |
| 500 ' #i2: \'i2\',\n' |
| 501 ' #i3: \'i3\',\n' |
| 502 ' }));\n'); |
| 503 }); |
| 504 |
| 505 test('query', () { |
| 506 var lib = provider.libraryFor('/common.dart'); |
| 507 var options = new QueryOptions(includeInherited: true, |
| 508 withAnnotations: [lib.getType('Annot')]); |
404 recorder.runQuery(lib.getType('H'), options); | 509 recorder.runQuery(lib.getType('H'), options); |
405 final a1Annot = 'annotations: const [smoke_0.a1]'; | 510 final a1Annot = 'annotations: const [smoke_0.a1]'; |
406 final a3Annot = 'annotations: const [smoke_0.a3]'; | 511 final a3Annot = 'annotations: const [smoke_0.a3]'; |
407 final exprAnnot = 'annotations: const [const smoke_0.Annot(1)]'; | 512 final exprAnnot = 'annotations: const [const smoke_0.Annot(1)]'; |
408 checkResults(generator, | 513 checkResults(generator, |
409 imports: [ | 514 imports: [ |
410 "import '/common.dart' as smoke_0;", | 515 "import '/common.dart' as smoke_0;", |
411 ], | 516 ], |
412 initCall: | 517 initCall: |
413 'useGeneratedCode(new StaticConfiguration(\n' | 518 'useGeneratedCode(new StaticConfiguration(\n' |
414 ' checkedMode: false,\n' | 519 ' checkedMode: false,\n' |
| 520 ' getters: {\n' |
| 521 ' #b: (o) => o.b,\n' |
| 522 ' #f: (o) => o.f,\n' |
| 523 ' #g: (o) => o.g,\n' |
| 524 ' #i: (o) => o.i,\n' |
| 525 ' #j: (o) => o.j,\n' |
| 526 ' },\n' |
| 527 ' setters: {\n' // #i3 is final |
| 528 ' #b: (o, v) { o.b = v; },\n' |
| 529 ' #f: (o, v) { o.f = v; },\n' |
| 530 ' #g: (o, v) { o.g = v; },\n' |
| 531 ' #i: (o, v) { o.i = v; },\n' |
| 532 ' #j: (o, v) { o.j = v; },\n' |
| 533 ' },\n' |
415 ' parents: {\n' | 534 ' parents: {\n' |
416 ' smoke_0.H: smoke_0.G,\n' | 535 ' smoke_0.H: smoke_0.G,\n' |
417 ' },\n' | 536 ' },\n' |
418 ' declarations: {\n' | 537 ' declarations: {\n' |
419 ' smoke_0.G: {\n' | 538 ' smoke_0.G: {\n' |
420 ' #b: const Declaration(#b, int, $a1Annot),\n' | 539 ' #b: const Declaration(#b, int, $a1Annot),\n' |
421 ' },\n' | 540 ' },\n' |
422 ' smoke_0.H: {\n' | 541 ' smoke_0.H: {\n' |
423 ' #f: const Declaration(#f, int, $a1Annot),\n' | 542 ' #f: const Declaration(#f, int, $a1Annot),\n' |
424 ' #g: const Declaration(#g, int, $a1Annot),\n' | 543 ' #g: const Declaration(#g, int, $a1Annot),\n' |
425 ' #i: const Declaration(#i, int, $a3Annot),\n' | 544 ' #i: const Declaration(#i, int, $a3Annot),\n' |
426 ' #j: const Declaration(#j, int, $exprAnnot),\n' | 545 ' #j: const Declaration(#j, int, $exprAnnot),\n' |
427 ' },\n' | 546 ' },\n' |
| 547 ' },\n' |
| 548 ' names: {\n' |
| 549 ' #b: \'b\',\n' |
| 550 ' #f: \'f\',\n' |
| 551 ' #g: \'g\',\n' |
| 552 ' #i: \'i\',\n' |
| 553 ' #j: \'j\',\n' |
428 ' }));\n'); | 554 ' }));\n'); |
429 }); | 555 }); |
430 }); | 556 }); |
431 } | 557 } |
432 | 558 |
433 const _SOURCES = const { | 559 const _SOURCES = const { |
434 '/a.dart': ''' | 560 '/a.dart': ''' |
435 library a; | 561 library a; |
436 import '/b.dart'; | 562 import '/b.dart'; |
437 | 563 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 } | 666 } |
541 | 667 |
542 class H extends G { | 668 class H extends G { |
543 int e; | 669 int e; |
544 @a1 int f; | 670 @a1 int f; |
545 @a1 int g; | 671 @a1 int g; |
546 @a2 int h; | 672 @a2 int h; |
547 @a3 int i; | 673 @a3 int i; |
548 @Annot(1) int j; | 674 @Annot(1) int j; |
549 } | 675 } |
| 676 |
| 677 class I { |
| 678 dynamic i1; |
| 679 get i2 => null; |
| 680 set i2(v) {} |
| 681 G get i3; |
| 682 } |
550 ''' | 683 ''' |
551 }; | 684 }; |
552 | 685 |
553 resolveImportUrl(LibraryElement lib) => | 686 resolveImportUrl(LibraryElement lib) => |
554 lib.isDartCore ? 'dart:core' : '/${lib.displayName}.dart'; | 687 lib.isDartCore ? 'dart:core' : '/${lib.displayName}.dart'; |
OLD | NEW |