| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 }); | 60 }); |
| 61 | 61 |
| 62 test('multiple mixins', () { | 62 test('multiple mixins', () { |
| 63 var lib = provider.libraryFor('/a.dart'); | 63 var lib = provider.libraryFor('/a.dart'); |
| 64 recorder.lookupParent(lib.getType('F')); | 64 recorder.lookupParent(lib.getType('F')); |
| 65 | 65 |
| 66 checkResults(generator, | 66 checkResults(generator, |
| 67 imports: [ | 67 imports: [ |
| 68 "import '/a.dart' as smoke_0;", | 68 "import '/a.dart' as smoke_0;", |
| 69 ], | 69 ], |
| 70 topLevel: | 70 topLevel: |
| 71 'abstract class _M0 {} // A & D1\n' | 71 'abstract class _M0 {} // A & D1\n' |
| 72 'abstract class _M1 {} // _M0 & D2\n' | 72 'abstract class _M1 {} // _M0 & D2\n' |
| 73 'abstract class _M2 {} // _M1 & D3\n', | 73 'abstract class _M2 {} // _M1 & D3\n', |
| 74 initCall: | 74 initCall: |
| 75 'useGeneratedCode(new StaticConfiguration(\n' | 75 'useGeneratedCode(new StaticConfiguration(\n' |
| 76 ' checkedMode: false,\n' | 76 ' checkedMode: false,\n' |
| 77 ' parents: {\n' | 77 ' parents: {\n' |
| 78 ' smoke_0.F: _M2,\n' | 78 ' smoke_0.F: _M2,\n' |
| 79 ' _M0: smoke_0.A,\n' | 79 ' _M0: smoke_0.A,\n' |
| 80 ' _M1: _M0,\n' | 80 ' _M1: _M0,\n' |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 ' #b: const Declaration(#b, int, $a1Annot),\n' | 566 ' #b: const Declaration(#b, int, $a1Annot),\n' |
| 567 ' },\n' | 567 ' },\n' |
| 568 ' smoke_0.H: {\n' | 568 ' smoke_0.H: {\n' |
| 569 ' #f: const Declaration(#f, int, $a1Annot),\n' | 569 ' #f: const Declaration(#f, int, $a1Annot),\n' |
| 570 ' #g: const Declaration(#g, int, $a1Annot),\n' | 570 ' #g: const Declaration(#g, int, $a1Annot),\n' |
| 571 ' #i: const Declaration(#i, int, $a3Annot),\n' | 571 ' #i: const Declaration(#i, int, $a3Annot),\n' |
| 572 ' #j: const Declaration(#j, int, $exprAnnot),\n' | 572 ' #j: const Declaration(#j, int, $exprAnnot),\n' |
| 573 ' },\n' | 573 ' },\n' |
| 574 ' }));\n'); | 574 ' }));\n'); |
| 575 }); | 575 }); |
| 576 |
| 577 test('type annotation with named arguments', () { |
| 578 var lib = provider.libraryFor('/common.dart'); |
| 579 var options = new QueryOptions(includeInherited: true, |
| 580 withAnnotations: [lib.getType('AnnotC')]); |
| 581 recorder.runQuery(lib.getType('K'), options, includeAccessors: false); |
| 582 final kAnnot = 'annotations: const [const smoke_0.AnnotC(named: true)]'; |
| 583 final k2Annot = 'annotations: const [const smoke_0.AnnotC()]'; |
| 584 checkResults(generator, |
| 585 imports: [ |
| 586 "import '/common.dart' as smoke_0;", |
| 587 ], |
| 588 initCall: |
| 589 'useGeneratedCode(new StaticConfiguration(\n' |
| 590 ' checkedMode: false,\n' |
| 591 ' declarations: {\n' |
| 592 ' smoke_0.K: {\n' |
| 593 ' #k: const Declaration(#k, int, $kAnnot),\n' |
| 594 ' #k2: const Declaration(#k2, int, $k2Annot),\n' |
| 595 ' },\n' |
| 596 ' }));\n'); |
| 597 }); |
| 576 }); | 598 }); |
| 577 | 599 |
| 578 group('with accessors', () { | 600 group('with accessors', () { |
| 579 test('lookup member', () { | 601 test('lookup member', () { |
| 580 var lib = provider.libraryFor('/common.dart'); | 602 var lib = provider.libraryFor('/common.dart'); |
| 581 recorder.lookupMember(lib.getType('I'), 'i1'); | 603 recorder.lookupMember(lib.getType('I'), 'i1'); |
| 582 recorder.lookupMember(lib.getType('I'), 'i2'); | 604 recorder.lookupMember(lib.getType('I'), 'i2'); |
| 583 recorder.lookupMember(lib.getType('I'), 'i3'); | 605 recorder.lookupMember(lib.getType('I'), 'i3'); |
| 584 recorder.lookupMember(lib.getType('I'), 'm4'); | 606 recorder.lookupMember(lib.getType('I'), 'm4'); |
| 585 checkResults(generator, | 607 checkResults(generator, |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 class E2 extends E {} | 816 class E2 extends E {} |
| 795 | 817 |
| 796 class F { | 818 class F { |
| 797 static int staticMethod(A a) => a.i; | 819 static int staticMethod(A a) => a.i; |
| 798 } | 820 } |
| 799 | 821 |
| 800 class F2 extends F {} | 822 class F2 extends F {} |
| 801 | 823 |
| 802 class Annot { const Annot(int ignore); } | 824 class Annot { const Annot(int ignore); } |
| 803 class AnnotB extends Annot { const AnnotB(); } | 825 class AnnotB extends Annot { const AnnotB(); } |
| 826 class AnnotC { const AnnotC({bool named: false}); } |
| 804 const a1 = const Annot(0); | 827 const a1 = const Annot(0); |
| 805 const a2 = 32; | 828 const a2 = 32; |
| 806 const a3 = const AnnotB(); | 829 const a3 = const AnnotB(); |
| 807 | 830 |
| 808 | 831 |
| 809 class G { | 832 class G { |
| 810 int a; | 833 int a; |
| 811 @a1 int b; | 834 @a1 int b; |
| 812 int c; | 835 int c; |
| 813 @a2 int d; | 836 @a2 int d; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 830 G m4() {}; | 853 G m4() {}; |
| 831 } | 854 } |
| 832 | 855 |
| 833 class J1 { | 856 class J1 { |
| 834 int i; | 857 int i; |
| 835 } | 858 } |
| 836 class J2 extends J1 { | 859 class J2 extends J1 { |
| 837 } | 860 } |
| 838 class J3 extends J2 { | 861 class J3 extends J2 { |
| 839 } | 862 } |
| 863 |
| 864 class K { |
| 865 @AnnotC(named: true) int k; |
| 866 @AnnotC() int k2; |
| 867 } |
| 840 ''' | 868 ''' |
| 841 }; | 869 }; |
| 842 | 870 |
| 843 resolveImportUrl(LibraryElement lib) => | 871 resolveImportUrl(LibraryElement lib) => |
| 844 lib.isDartCore ? 'dart:core' : '/${lib.displayName}.dart'; | 872 lib.isDartCore ? 'dart:core' : '/${lib.displayName}.dart'; |
| OLD | NEW |