| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analyzer.test.src.summary.summary_common; | 5 library analyzer.test.src.summary.summary_common; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 2687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2698 } | 2698 } |
| 2699 | 2699 |
| 2700 test_constructor_implicit() { | 2700 test_constructor_implicit() { |
| 2701 // Implicit constructors are not serialized. | 2701 // Implicit constructors are not serialized. |
| 2702 UnlinkedExecutable executable = findExecutable(null, | 2702 UnlinkedExecutable executable = findExecutable(null, |
| 2703 executables: serializeClassText('class C { C(); }').executables, | 2703 executables: serializeClassText('class C { C(); }').executables, |
| 2704 failIfAbsent: false); | 2704 failIfAbsent: false); |
| 2705 expect(executable, isNull); | 2705 expect(executable, isNull); |
| 2706 } | 2706 } |
| 2707 | 2707 |
| 2708 test_constructor_initializers_field() { |
| 2709 UnlinkedExecutable executable = |
| 2710 findExecutable('', executables: serializeClassText(r''' |
| 2711 class C { |
| 2712 final x; |
| 2713 const C() : x = 42; |
| 2714 } |
| 2715 ''').executables); |
| 2716 expect(executable.constantInitializers, hasLength(1)); |
| 2717 UnlinkedConstructorInitializer initializer = |
| 2718 executable.constantInitializers[0]; |
| 2719 expect(initializer.kind, UnlinkedConstructorInitializerKind.field); |
| 2720 expect(initializer.name, 'x'); |
| 2721 _assertUnlinkedConst(initializer.expression, |
| 2722 operators: [UnlinkedConstOperation.pushInt], ints: [42]); |
| 2723 expect(initializer.arguments, isEmpty); |
| 2724 } |
| 2725 |
| 2726 test_constructor_initializers_field_withParameter() { |
| 2727 UnlinkedExecutable executable = |
| 2728 findExecutable('', executables: serializeClassText(r''' |
| 2729 class C { |
| 2730 final x; |
| 2731 const C(int p) : x = p; |
| 2732 } |
| 2733 ''').executables); |
| 2734 expect(executable.constantInitializers, hasLength(1)); |
| 2735 UnlinkedConstructorInitializer initializer = |
| 2736 executable.constantInitializers[0]; |
| 2737 expect(initializer.kind, UnlinkedConstructorInitializerKind.field); |
| 2738 expect(initializer.name, 'x'); |
| 2739 _assertUnlinkedConst(initializer.expression, |
| 2740 operators: [UnlinkedConstOperation.pushConstructorParameter], |
| 2741 strings: ['p']); |
| 2742 expect(initializer.arguments, isEmpty); |
| 2743 } |
| 2744 |
| 2745 test_constructor_initializers_notConst() { |
| 2746 UnlinkedExecutable executable = |
| 2747 findExecutable('', executables: serializeClassText(r''' |
| 2748 class C { |
| 2749 final x; |
| 2750 C() : x = 42; |
| 2751 } |
| 2752 ''').executables); |
| 2753 expect(executable.constantInitializers, isEmpty); |
| 2754 } |
| 2755 |
| 2756 test_constructor_initializers_superInvocation_named() { |
| 2757 UnlinkedExecutable executable = |
| 2758 findExecutable('', executables: serializeClassText(r''' |
| 2759 class A { |
| 2760 const A.aaa(int p); |
| 2761 } |
| 2762 class C extends A { |
| 2763 const C() : super.aaa(42); |
| 2764 } |
| 2765 ''').executables); |
| 2766 expect(executable.constantInitializers, hasLength(1)); |
| 2767 UnlinkedConstructorInitializer initializer = |
| 2768 executable.constantInitializers[0]; |
| 2769 expect( |
| 2770 initializer.kind, UnlinkedConstructorInitializerKind.superInvocation); |
| 2771 expect(initializer.name, 'aaa'); |
| 2772 expect(initializer.expression, isNull); |
| 2773 expect(initializer.arguments, hasLength(1)); |
| 2774 _assertUnlinkedConst(initializer.arguments[0], |
| 2775 operators: [UnlinkedConstOperation.pushInt], ints: [42]); |
| 2776 } |
| 2777 |
| 2778 test_constructor_initializers_superInvocation_unnamed() { |
| 2779 UnlinkedExecutable executable = |
| 2780 findExecutable('ccc', executables: serializeClassText(r''' |
| 2781 class A { |
| 2782 const A(int p); |
| 2783 } |
| 2784 class C extends A { |
| 2785 const C.ccc() : super(42); |
| 2786 } |
| 2787 ''').executables); |
| 2788 expect(executable.constantInitializers, hasLength(1)); |
| 2789 UnlinkedConstructorInitializer initializer = |
| 2790 executable.constantInitializers[0]; |
| 2791 expect( |
| 2792 initializer.kind, UnlinkedConstructorInitializerKind.superInvocation); |
| 2793 expect(initializer.name, ''); |
| 2794 expect(initializer.expression, isNull); |
| 2795 expect(initializer.arguments, hasLength(1)); |
| 2796 _assertUnlinkedConst(initializer.arguments[0], |
| 2797 operators: [UnlinkedConstOperation.pushInt], ints: [42]); |
| 2798 } |
| 2799 |
| 2800 test_constructor_initializers_thisInvocation_named() { |
| 2801 UnlinkedExecutable executable = |
| 2802 findExecutable('', executables: serializeClassText(r''' |
| 2803 class C { |
| 2804 const C() : this.named(1, 'bbb'); |
| 2805 const C.named(int a, String b); |
| 2806 } |
| 2807 ''').executables); |
| 2808 expect(executable.constantInitializers, hasLength(1)); |
| 2809 UnlinkedConstructorInitializer initializer = |
| 2810 executable.constantInitializers[0]; |
| 2811 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); |
| 2812 expect(initializer.name, 'named'); |
| 2813 expect(initializer.expression, isNull); |
| 2814 expect(initializer.arguments, hasLength(2)); |
| 2815 _assertUnlinkedConst(initializer.arguments[0], |
| 2816 operators: [UnlinkedConstOperation.pushInt], ints: [1]); |
| 2817 _assertUnlinkedConst(initializer.arguments[1], |
| 2818 operators: [UnlinkedConstOperation.pushString], strings: ['bbb']); |
| 2819 } |
| 2820 |
| 2821 test_constructor_initializers_thisInvocation_unnamed() { |
| 2822 UnlinkedExecutable executable = |
| 2823 findExecutable('named', executables: serializeClassText(r''' |
| 2824 class C { |
| 2825 const C.named() : this(1, 'bbb'); |
| 2826 const C(int a, String b); |
| 2827 } |
| 2828 ''').executables); |
| 2829 expect(executable.constantInitializers, hasLength(1)); |
| 2830 UnlinkedConstructorInitializer initializer = |
| 2831 executable.constantInitializers[0]; |
| 2832 expect(initializer.kind, UnlinkedConstructorInitializerKind.thisInvocation); |
| 2833 expect(initializer.name, ''); |
| 2834 expect(initializer.expression, isNull); |
| 2835 expect(initializer.arguments, hasLength(2)); |
| 2836 _assertUnlinkedConst(initializer.arguments[0], |
| 2837 operators: [UnlinkedConstOperation.pushInt], ints: [1]); |
| 2838 _assertUnlinkedConst(initializer.arguments[1], |
| 2839 operators: [UnlinkedConstOperation.pushString], strings: ['bbb']); |
| 2840 } |
| 2841 |
| 2708 test_constructor_initializing_formal() { | 2842 test_constructor_initializing_formal() { |
| 2709 UnlinkedExecutable executable = findExecutable('', | 2843 UnlinkedExecutable executable = findExecutable('', |
| 2710 executables: | 2844 executables: |
| 2711 serializeClassText('class C { C(this.x); final x; }').executables); | 2845 serializeClassText('class C { C(this.x); final x; }').executables); |
| 2712 UnlinkedParam parameter = executable.parameters[0]; | 2846 UnlinkedParam parameter = executable.parameters[0]; |
| 2713 expect(parameter.isInitializingFormal, isTrue); | 2847 expect(parameter.isInitializingFormal, isTrue); |
| 2714 } | 2848 } |
| 2715 | 2849 |
| 2716 test_constructor_initializing_formal_explicit_type() { | 2850 test_constructor_initializing_formal_explicit_type() { |
| 2717 UnlinkedExecutable executable = findExecutable('', | 2851 UnlinkedExecutable executable = findExecutable('', |
| (...skipping 2141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4859 | 4993 |
| 4860 test_metadata_typeParameter_ofClassTypeAlias() { | 4994 test_metadata_typeParameter_ofClassTypeAlias() { |
| 4861 checkAnnotationA(serializeClassText( | 4995 checkAnnotationA(serializeClassText( |
| 4862 'const a = null; class C<@a T> = D with E; class D {} class E {}', | 4996 'const a = null; class C<@a T> = D with E; class D {} class E {}', |
| 4863 className: 'C') | 4997 className: 'C') |
| 4864 .typeParameters[0] | 4998 .typeParameters[0] |
| 4865 .annotations); | 4999 .annotations); |
| 4866 } | 5000 } |
| 4867 | 5001 |
| 4868 test_metadata_typeParameter_ofFunction() { | 5002 test_metadata_typeParameter_ofFunction() { |
| 4869 checkAnnotationA( | 5003 checkAnnotationA(serializeExecutableText('const a = null; f<@a T>() {}') |
| 4870 serializeExecutableText('const a = null; f<@a T>() {}') | 5004 .typeParameters[0] |
| 4871 .typeParameters[0] | 5005 .annotations); |
| 4872 .annotations); | |
| 4873 } | 5006 } |
| 4874 | 5007 |
| 4875 test_metadata_typeParameter_ofTypedef() { | 5008 test_metadata_typeParameter_ofTypedef() { |
| 4876 checkAnnotationA(serializeTypedefText('const a = null; typedef F<@a T>();') | 5009 checkAnnotationA(serializeTypedefText('const a = null; typedef F<@a T>();') |
| 4877 .typeParameters[0] | 5010 .typeParameters[0] |
| 4878 .annotations); | 5011 .annotations); |
| 4879 } | 5012 } |
| 4880 | 5013 |
| 4881 test_method_documented() { | 5014 test_method_documented() { |
| 4882 String text = ''' | 5015 String text = ''' |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5761 final String absoluteUri; | 5894 final String absoluteUri; |
| 5762 final String relativeUri; | 5895 final String relativeUri; |
| 5763 final int numTypeParameters; | 5896 final int numTypeParameters; |
| 5764 | 5897 |
| 5765 _PrefixExpectation(this.kind, this.name, | 5898 _PrefixExpectation(this.kind, this.name, |
| 5766 {this.inLibraryDefiningUnit: false, | 5899 {this.inLibraryDefiningUnit: false, |
| 5767 this.absoluteUri, | 5900 this.absoluteUri, |
| 5768 this.relativeUri, | 5901 this.relativeUri, |
| 5769 this.numTypeParameters: 0}); | 5902 this.numTypeParameters: 0}); |
| 5770 } | 5903 } |
| OLD | NEW |