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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 test('missing declaration', () { | 148 test('missing declaration', () { |
149 recorder.lookupMember(lib.getType('A'), 'q', includeAccessors: false); | 149 recorder.lookupMember(lib.getType('A'), 'q', includeAccessors: false); |
150 checkResults(generator, | 150 checkResults(generator, |
151 imports: [ | 151 imports: [ |
152 "import '/common.dart' as smoke_0;", | 152 "import '/common.dart' as smoke_0;", |
153 ], | 153 ], |
154 initCall: | 154 initCall: |
155 'useGeneratedCode(new StaticConfiguration(\n' | 155 'useGeneratedCode(new StaticConfiguration(\n' |
156 ' checkedMode: false,\n' | 156 ' checkedMode: false,\n' |
157 ' declarations: {\n' | 157 ' declarations: {\n' |
158 ' smoke_0.A: const {},\n' | 158 ' smoke_0.A: {},\n' |
159 ' }));\n'); | 159 ' }));\n'); |
160 }); | 160 }); |
161 | 161 |
162 test('field declaration', () { | 162 test('field declaration', () { |
163 recorder.lookupMember(lib.getType('A'), 'i', includeAccessors: false); | 163 recorder.lookupMember(lib.getType('A'), 'i', includeAccessors: false); |
164 checkResults(generator, | 164 checkResults(generator, |
165 imports: [ | 165 imports: [ |
166 "import '/common.dart' as smoke_0;", | 166 "import '/common.dart' as smoke_0;", |
167 ], | 167 ], |
168 initCall: | 168 initCall: |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 test('inherited field - not recursive', () { | 295 test('inherited field - not recursive', () { |
296 recorder.lookupMember(lib.getType('D'), 'i', includeAccessors: false); | 296 recorder.lookupMember(lib.getType('D'), 'i', includeAccessors: false); |
297 checkResults(generator, | 297 checkResults(generator, |
298 imports: [ | 298 imports: [ |
299 "import '/common.dart' as smoke_0;", | 299 "import '/common.dart' as smoke_0;", |
300 ], | 300 ], |
301 initCall: | 301 initCall: |
302 'useGeneratedCode(new StaticConfiguration(\n' | 302 'useGeneratedCode(new StaticConfiguration(\n' |
303 ' checkedMode: false,\n' | 303 ' checkedMode: false,\n' |
304 ' declarations: {\n' | 304 ' declarations: {\n' |
305 ' smoke_0.D: const {},\n' | 305 ' smoke_0.D: {},\n' |
306 ' }));\n'); | 306 ' }));\n'); |
307 }); | 307 }); |
308 | 308 |
309 test('inherited field - recursive', () { | 309 test('inherited field - recursive', () { |
310 recorder.lookupMember(lib.getType('D'), 'i', recursive: true, | 310 recorder.lookupMember(lib.getType('D'), 'i', recursive: true, |
311 includeAccessors: false); | 311 includeAccessors: false); |
312 checkResults(generator, | 312 checkResults(generator, |
313 imports: [ | 313 imports: [ |
314 "import '/common.dart' as smoke_0;", | 314 "import '/common.dart' as smoke_0;", |
315 ], | 315 ], |
316 topLevel: 'abstract class _M0 {} // C & A\n', | 316 topLevel: 'abstract class _M0 {} // C & A\n', |
317 initCall: | 317 initCall: |
318 'useGeneratedCode(new StaticConfiguration(\n' | 318 'useGeneratedCode(new StaticConfiguration(\n' |
319 ' checkedMode: false,\n' | 319 ' checkedMode: false,\n' |
320 ' parents: {\n' | 320 ' parents: {\n' |
321 ' smoke_0.D: _M0,\n' | 321 ' smoke_0.D: _M0,\n' |
322 ' _M0: smoke_0.C,\n' | 322 ' _M0: smoke_0.C,\n' |
323 ' },\n' | 323 ' },\n' |
324 ' declarations: {\n' | 324 ' declarations: {\n' |
325 ' smoke_0.D: const {},\n' | 325 ' smoke_0.D: {},\n' |
326 ' _M0: {\n' | 326 ' _M0: {\n' |
327 ' #i: const Declaration(#i, int),\n' | 327 ' #i: const Declaration(#i, int),\n' |
328 ' },\n' | 328 ' },\n' |
329 ' }));\n'); | 329 ' }));\n'); |
330 }); | 330 }); |
331 | 331 |
332 test('inherited field - recursive deep', () { | 332 test('inherited field - recursive deep', () { |
333 recorder.lookupMember(lib.getType('J3'), 'i', recursive: true, | 333 recorder.lookupMember(lib.getType('J3'), 'i', recursive: true, |
334 includeAccessors: false); | 334 includeAccessors: false); |
335 checkResults(generator, | 335 checkResults(generator, |
336 imports: [ | 336 imports: [ |
337 "import '/common.dart' as smoke_0;", | 337 "import '/common.dart' as smoke_0;", |
338 ], | 338 ], |
339 initCall: | 339 initCall: |
340 'useGeneratedCode(new StaticConfiguration(\n' | 340 'useGeneratedCode(new StaticConfiguration(\n' |
341 ' checkedMode: false,\n' | 341 ' checkedMode: false,\n' |
342 ' parents: {\n' | 342 ' parents: {\n' |
343 ' smoke_0.J2: smoke_0.J1,\n' | 343 ' smoke_0.J2: smoke_0.J1,\n' |
344 ' smoke_0.J3: smoke_0.J2,\n' | 344 ' smoke_0.J3: smoke_0.J2,\n' |
345 ' },\n' | 345 ' },\n' |
346 ' declarations: {\n' | 346 ' declarations: {\n' |
347 ' smoke_0.J1: {\n' | 347 ' smoke_0.J1: {\n' |
348 ' #i: const Declaration(#i, int),\n' | 348 ' #i: const Declaration(#i, int),\n' |
349 ' },\n' | 349 ' },\n' |
350 ' smoke_0.J2: const {},\n' | 350 ' smoke_0.J2: {},\n' |
351 ' smoke_0.J3: const {},\n' | 351 ' smoke_0.J3: {},\n' |
352 ' }));\n'); | 352 ' }));\n'); |
353 }); | 353 }); |
354 | 354 |
355 test('inherited field - recursive - includeUpTo', () { | 355 test('inherited field - recursive - includeUpTo', () { |
356 recorder.lookupMember(lib.getType('J3'), 'i', recursive: true, | 356 recorder.lookupMember(lib.getType('J3'), 'i', recursive: true, |
357 includeAccessors: false, includeUpTo: lib.getType('J1')); | 357 includeAccessors: false, includeUpTo: lib.getType('J1')); |
358 checkResults(generator, | 358 checkResults(generator, |
359 imports: [ | 359 imports: [ |
360 "import '/common.dart' as smoke_0;", | 360 "import '/common.dart' as smoke_0;", |
361 ], | 361 ], |
362 initCall: | 362 initCall: |
363 'useGeneratedCode(new StaticConfiguration(\n' | 363 'useGeneratedCode(new StaticConfiguration(\n' |
364 ' checkedMode: false,\n' | 364 ' checkedMode: false,\n' |
365 ' parents: {\n' | 365 ' parents: {\n' |
366 ' smoke_0.J2: smoke_0.J1,\n' | 366 ' smoke_0.J2: smoke_0.J1,\n' |
367 ' smoke_0.J3: smoke_0.J2,\n' | 367 ' smoke_0.J3: smoke_0.J2,\n' |
368 ' },\n' | 368 ' },\n' |
369 ' declarations: {\n' | 369 ' declarations: {\n' |
370 ' smoke_0.J2: const {},\n' | 370 ' smoke_0.J2: {},\n' |
371 ' smoke_0.J3: const {},\n' | 371 ' smoke_0.J3: {},\n' |
372 ' }));\n'); | 372 ' }));\n'); |
373 }); | 373 }); |
374 }); | 374 }); |
375 | 375 |
376 group('query', () { | 376 group('query', () { |
377 test('default query', () { | 377 test('default query', () { |
378 var options = new QueryOptions(); | 378 var options = new QueryOptions(); |
379 var lib = provider.libraryFor('/common.dart'); | 379 var lib = provider.libraryFor('/common.dart'); |
380 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); | 380 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); |
381 checkResults(generator, | 381 checkResults(generator, |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 | 863 |
864 class K { | 864 class K { |
865 @AnnotC(named: true) int k; | 865 @AnnotC(named: true) int k; |
866 @AnnotC() int k2; | 866 @AnnotC() int k2; |
867 } | 867 } |
868 ''' | 868 ''' |
869 }; | 869 }; |
870 | 870 |
871 resolveImportUrl(LibraryElement lib) => | 871 resolveImportUrl(LibraryElement lib) => |
872 lib.isDartCore ? 'dart:core' : '/${lib.displayName}.dart'; | 872 lib.isDartCore ? 'dart:core' : '/${lib.displayName}.dart'; |
OLD | NEW |