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

Side by Side Diff: pkg/analyzer/test/generated/non_error_resolver_test.dart

Issue 975453004: Reformat (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
OLDNEW
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 engine.non_error_resolver_test; 5 library engine.non_error_resolver_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/error.dart'; 9 import 'package:analyzer/src/generated/error.dart';
10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; 10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
11 import 'package:analyzer/src/generated/source_io.dart'; 11 import 'package:analyzer/src/generated/source_io.dart';
12 import 'package:unittest/unittest.dart' as _ut; 12 import 'package:unittest/unittest.dart' as _ut;
13 13
14 import '../reflective_tests.dart'; 14 import '../reflective_tests.dart';
15 import 'resolver_test.dart'; 15 import 'resolver_test.dart';
16 import 'test_support.dart'; 16 import 'test_support.dart';
17 17
18
19 main() { 18 main() {
20 _ut.groupSep = ' | '; 19 _ut.groupSep = ' | ';
21 runReflectiveTests(NonErrorResolverTest); 20 runReflectiveTests(NonErrorResolverTest);
22 } 21 }
23 22
24 @reflectiveTest 23 @reflectiveTest
25 class NonErrorResolverTest extends ResolverTestCase { 24 class NonErrorResolverTest extends ResolverTestCase {
26 void fail_undefinedEnumConstant() { 25 void fail_undefinedEnumConstant() {
27 Source source = addSource(r''' 26 Source source = addSource(r'''
28 enum E { ONE } 27 enum E { ONE }
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 abstract class A { 755 abstract class A {
757 /// [p] 756 /// [p]
758 A(int p) {} 757 A(int p) {}
759 }'''; 758 }''';
760 Source source = addSource(code); 759 Source source = addSource(code);
761 resolve(source); 760 resolve(source);
762 assertNoErrors(source); 761 assertNoErrors(source);
763 verify([source]); 762 verify([source]);
764 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 763 CompilationUnit unit = analysisContext.parseCompilationUnit(source);
765 { 764 {
766 SimpleIdentifier ref = 765 SimpleIdentifier ref = EngineTestCase.findNode(
767 EngineTestCase.findNode(unit, code, "p]", (node) => node is SimpleIden tifier); 766 unit, code, "p]", (node) => node is SimpleIdentifier);
768 EngineTestCase.assertInstanceOf( 767 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement,
769 (obj) => obj is ParameterElement, 768 ParameterElement, ref.staticElement);
770 ParameterElement,
771 ref.staticElement);
772 } 769 }
773 } 770 }
774 771
775 void test_commentReference_beforeFunction_blockBody() { 772 void test_commentReference_beforeFunction_blockBody() {
776 String code = r''' 773 String code = r'''
777 /// [p] 774 /// [p]
778 foo(int p) { 775 foo(int p) {
779 }'''; 776 }''';
780 Source source = addSource(code); 777 Source source = addSource(code);
781 resolve(source); 778 resolve(source);
782 assertNoErrors(source); 779 assertNoErrors(source);
783 verify([source]); 780 verify([source]);
784 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 781 CompilationUnit unit = analysisContext.parseCompilationUnit(source);
785 SimpleIdentifier ref = 782 SimpleIdentifier ref = EngineTestCase.findNode(
786 EngineTestCase.findNode(unit, code, "p]", (node) => node is SimpleIdenti fier); 783 unit, code, "p]", (node) => node is SimpleIdentifier);
787 EngineTestCase.assertInstanceOf( 784 EngineTestCase.assertInstanceOf(
788 (obj) => obj is ParameterElement, 785 (obj) => obj is ParameterElement, ParameterElement, ref.staticElement);
789 ParameterElement,
790 ref.staticElement);
791 } 786 }
792 787
793 void test_commentReference_beforeFunction_expressionBody() { 788 void test_commentReference_beforeFunction_expressionBody() {
794 String code = r''' 789 String code = r'''
795 /// [p] 790 /// [p]
796 foo(int p) => null;'''; 791 foo(int p) => null;''';
797 Source source = addSource(code); 792 Source source = addSource(code);
798 resolve(source); 793 resolve(source);
799 assertNoErrors(source); 794 assertNoErrors(source);
800 verify([source]); 795 verify([source]);
801 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 796 CompilationUnit unit = analysisContext.parseCompilationUnit(source);
802 SimpleIdentifier ref = 797 SimpleIdentifier ref = EngineTestCase.findNode(
803 EngineTestCase.findNode(unit, code, "p]", (node) => node is SimpleIdenti fier); 798 unit, code, "p]", (node) => node is SimpleIdentifier);
804 EngineTestCase.assertInstanceOf( 799 EngineTestCase.assertInstanceOf(
805 (obj) => obj is ParameterElement, 800 (obj) => obj is ParameterElement, ParameterElement, ref.staticElement);
806 ParameterElement,
807 ref.staticElement);
808 } 801 }
809 802
810 void test_commentReference_beforeMethod() { 803 void test_commentReference_beforeMethod() {
811 String code = r''' 804 String code = r'''
812 abstract class A { 805 abstract class A {
813 /// [p1] 806 /// [p1]
814 ma(int p1) {} 807 ma(int p1) {}
815 /// [p2] 808 /// [p2]
816 mb(int p2); 809 mb(int p2);
817 }'''; 810 }''';
818 Source source = addSource(code); 811 Source source = addSource(code);
819 resolve(source); 812 resolve(source);
820 assertNoErrors(source); 813 assertNoErrors(source);
821 verify([source]); 814 verify([source]);
822 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 815 CompilationUnit unit = analysisContext.parseCompilationUnit(source);
823 { 816 {
824 SimpleIdentifier ref = 817 SimpleIdentifier ref = EngineTestCase.findNode(
825 EngineTestCase.findNode(unit, code, "p1]", (node) => node is SimpleIde ntifier); 818 unit, code, "p1]", (node) => node is SimpleIdentifier);
826 EngineTestCase.assertInstanceOf( 819 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement,
827 (obj) => obj is ParameterElement, 820 ParameterElement, ref.staticElement);
828 ParameterElement,
829 ref.staticElement);
830 } 821 }
831 { 822 {
832 SimpleIdentifier ref = 823 SimpleIdentifier ref = EngineTestCase.findNode(
833 EngineTestCase.findNode(unit, code, "p2]", (node) => node is SimpleIde ntifier); 824 unit, code, "p2]", (node) => node is SimpleIdentifier);
834 EngineTestCase.assertInstanceOf( 825 EngineTestCase.assertInstanceOf((obj) => obj is ParameterElement,
835 (obj) => obj is ParameterElement, 826 ParameterElement, ref.staticElement);
836 ParameterElement,
837 ref.staticElement);
838 } 827 }
839 } 828 }
840 829
841 void test_commentReference_class() { 830 void test_commentReference_class() {
842 String code = r''' 831 String code = r'''
843 /// [foo] 832 /// [foo]
844 class A { 833 class A {
845 foo() {} 834 foo() {}
846 }'''; 835 }''';
847 Source source = addSource(code); 836 Source source = addSource(code);
848 resolve(source); 837 resolve(source);
849 assertNoErrors(source); 838 assertNoErrors(source);
850 verify([source]); 839 verify([source]);
851 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 840 CompilationUnit unit = analysisContext.parseCompilationUnit(source);
852 SimpleIdentifier ref = EngineTestCase.findNode( 841 SimpleIdentifier ref = EngineTestCase.findNode(
853 unit, 842 unit, code, "foo]", (node) => node is SimpleIdentifier);
854 code,
855 "foo]",
856 (node) => node is SimpleIdentifier);
857 EngineTestCase.assertInstanceOf( 843 EngineTestCase.assertInstanceOf(
858 (obj) => obj is MethodElement, 844 (obj) => obj is MethodElement, MethodElement, ref.staticElement);
859 MethodElement,
860 ref.staticElement);
861 } 845 }
862 846
863 void test_commentReference_setter() { 847 void test_commentReference_setter() {
864 String code = r''' 848 String code = r'''
865 class A { 849 class A {
866 /// [x] in A 850 /// [x] in A
867 mA() {} 851 mA() {}
868 set x(value) {} 852 set x(value) {}
869 } 853 }
870 class B extends A { 854 class B extends A {
871 /// [x] in B 855 /// [x] in B
872 mB() {} 856 mB() {}
873 } 857 }
874 '''; 858 ''';
875 Source source = addSource(code); 859 Source source = addSource(code);
876 resolve(source); 860 resolve(source);
877 assertNoErrors(source); 861 assertNoErrors(source);
878 verify([source]); 862 verify([source]);
879 CompilationUnit unit = analysisContext.parseCompilationUnit(source); 863 CompilationUnit unit = analysisContext.parseCompilationUnit(source);
880 { 864 {
881 SimpleIdentifier ref = EngineTestCase.findNode( 865 SimpleIdentifier ref = EngineTestCase.findNode(
882 unit, 866 unit, code, "x] in A", (node) => node is SimpleIdentifier);
883 code, 867 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement,
884 "x] in A", 868 PropertyAccessorElement, ref.staticElement);
885 (node) => node is SimpleIdentifier);
886 EngineTestCase.assertInstanceOf(
887 (obj) => obj is PropertyAccessorElement,
888 PropertyAccessorElement,
889 ref.staticElement);
890 } 869 }
891 { 870 {
892 SimpleIdentifier ref = EngineTestCase.findNode( 871 SimpleIdentifier ref = EngineTestCase.findNode(
893 unit, 872 unit, code, "x] in B", (node) => node is SimpleIdentifier);
894 code, 873 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement,
895 "x] in B", 874 PropertyAccessorElement, ref.staticElement);
896 (node) => node is SimpleIdentifier);
897 EngineTestCase.assertInstanceOf(
898 (obj) => obj is PropertyAccessorElement,
899 PropertyAccessorElement,
900 ref.staticElement);
901 } 875 }
902 } 876 }
903 877
904 void test_concreteClassWithAbstractMember() { 878 void test_concreteClassWithAbstractMember() {
905 Source source = addSource(r''' 879 Source source = addSource(r'''
906 abstract class A { 880 abstract class A {
907 m(); 881 m();
908 }'''); 882 }''');
909 resolve(source); 883 resolve(source);
910 assertNoErrors(source); 884 assertNoErrors(source);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 964
991 void test_constConstructorWithNonConstSuper_unresolved() { 965 void test_constConstructorWithNonConstSuper_unresolved() {
992 Source source = addSource(r''' 966 Source source = addSource(r'''
993 class A { 967 class A {
994 A.a(); 968 A.a();
995 } 969 }
996 class B extends A { 970 class B extends A {
997 const B(): super(); 971 const B(): super();
998 }'''); 972 }''');
999 resolve(source); 973 resolve(source);
1000 assertErrors( 974 assertErrors(source, [
1001 source, 975 CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT
1002 [CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT]); 976 ]);
1003 verify([source]); 977 verify([source]);
1004 } 978 }
1005 979
1006 void test_constConstructorWithNonFinalField_finalInstanceVar() { 980 void test_constConstructorWithNonFinalField_finalInstanceVar() {
1007 Source source = addSource(r''' 981 Source source = addSource(r'''
1008 class A { 982 class A {
1009 final int x = 0; 983 final int x = 0;
1010 const A(); 984 const A();
1011 }'''); 985 }''');
1012 resolve(source); 986 resolve(source);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 const A(); 1018 const A();
1045 set x(value) {} 1019 set x(value) {}
1046 get x {return 0;} 1020 get x {return 0;}
1047 }'''); 1021 }''');
1048 resolve(source); 1022 resolve(source);
1049 assertNoErrors(source); 1023 assertNoErrors(source);
1050 verify([source]); 1024 verify([source]);
1051 } 1025 }
1052 1026
1053 void test_constDeferredClass_new() { 1027 void test_constDeferredClass_new() {
1054 resolveWithErrors(<String>[r''' 1028 resolveWithErrors(<String>[
1029 r'''
1055 library lib1; 1030 library lib1;
1056 class A { 1031 class A {
1057 const A.b(); 1032 const A.b();
1058 }''', r''' 1033 }''',
1034 r'''
1059 library root; 1035 library root;
1060 import 'lib1.dart' deferred as a; 1036 import 'lib1.dart' deferred as a;
1061 main() { 1037 main() {
1062 new a.A.b(); 1038 new a.A.b();
1063 }'''], <ErrorCode>[]); 1039 }'''
1040 ], <ErrorCode>[]);
1064 } 1041 }
1065 1042
1066 void test_constEval_functionTypeLiteral() { 1043 void test_constEval_functionTypeLiteral() {
1067 Source source = addSource(r''' 1044 Source source = addSource(r'''
1068 typedef F(); 1045 typedef F();
1069 const C = F;'''); 1046 const C = F;''');
1070 resolve(source); 1047 resolve(source);
1071 assertNoErrors(source); 1048 assertNoErrors(source);
1072 verify([source]); 1049 verify([source]);
1073 } 1050 }
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 verify([source]); 1854 verify([source]);
1878 } 1855 }
1879 1856
1880 void test_importDuplicatedLibraryName() { 1857 void test_importDuplicatedLibraryName() {
1881 Source source = addSource(r''' 1858 Source source = addSource(r'''
1882 library test; 1859 library test;
1883 import 'lib.dart'; 1860 import 'lib.dart';
1884 import 'lib.dart';'''); 1861 import 'lib.dart';''');
1885 addNamedSource("/lib.dart", "library lib;"); 1862 addNamedSource("/lib.dart", "library lib;");
1886 resolve(source); 1863 resolve(source);
1887 assertErrors( 1864 assertErrors(source, [
1888 source, 1865 HintCode.UNUSED_IMPORT,
1889 [HintCode.UNUSED_IMPORT, HintCode.UNUSED_IMPORT, HintCode.DUPLICATE_IMPO RT]); 1866 HintCode.UNUSED_IMPORT,
1867 HintCode.DUPLICATE_IMPORT
1868 ]);
1890 verify([source]); 1869 verify([source]);
1891 } 1870 }
1892 1871
1893 void test_importOfNonLibrary_libraryDeclared() { 1872 void test_importOfNonLibrary_libraryDeclared() {
1894 Source source = addSource(r''' 1873 Source source = addSource(r'''
1895 library lib; 1874 library lib;
1896 import 'part.dart'; 1875 import 'part.dart';
1897 A a;'''); 1876 A a;''');
1898 addNamedSource("/part.dart", r''' 1877 addNamedSource("/part.dart", r'''
1899 library lib1; 1878 library lib1;
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
2814 void test_listElementTypeNotAssignable() { 2793 void test_listElementTypeNotAssignable() {
2815 Source source = addSource(r''' 2794 Source source = addSource(r'''
2816 var v1 = <int> [42]; 2795 var v1 = <int> [42];
2817 var v2 = const <int> [42];'''); 2796 var v2 = const <int> [42];''');
2818 resolve(source); 2797 resolve(source);
2819 assertNoErrors(source); 2798 assertNoErrors(source);
2820 verify([source]); 2799 verify([source]);
2821 } 2800 }
2822 2801
2823 void test_loadLibraryDefined() { 2802 void test_loadLibraryDefined() {
2824 resolveWithErrors(<String>[r''' 2803 resolveWithErrors(<String>[
2804 r'''
2825 library lib1; 2805 library lib1;
2826 foo() => 22;''', r''' 2806 foo() => 22;''',
2807 r'''
2827 import 'lib1.dart' deferred as other; 2808 import 'lib1.dart' deferred as other;
2828 main() { 2809 main() {
2829 other.loadLibrary().then((_) => other.foo()); 2810 other.loadLibrary().then((_) => other.foo());
2830 }'''], <ErrorCode>[]); 2811 }'''
2812 ], <ErrorCode>[]);
2831 } 2813 }
2832 2814
2833 void test_local_generator_async() { 2815 void test_local_generator_async() {
2834 Source source = addSource(''' 2816 Source source = addSource('''
2835 f() { 2817 f() {
2836 return () async* { yield 0; }; 2818 return () async* { yield 0; };
2837 } 2819 }
2838 '''); 2820 ''');
2839 resolve(source); 2821 resolve(source);
2840 assertNoErrors(source); 2822 assertNoErrors(source);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
3136 A() {} 3118 A() {}
3137 } 3119 }
3138 f() { 3120 f() {
3139 new A(); 3121 new A();
3140 }'''); 3122 }''');
3141 resolve(source); 3123 resolve(source);
3142 assertNoErrors(source); 3124 assertNoErrors(source);
3143 verify([source]); 3125 verify([source]);
3144 } 3126 }
3145 3127
3146 void 3128 void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcr etes_getter() {
3147 test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcre tes_getter() {
3148 Source source = addSource(r''' 3129 Source source = addSource(r'''
3149 class A { 3130 class A {
3150 int get g => 0; 3131 int get g => 0;
3151 } 3132 }
3152 abstract class B extends A { 3133 abstract class B extends A {
3153 int get g; 3134 int get g;
3154 } 3135 }
3155 class C extends B {}'''); 3136 class C extends B {}''');
3156 resolve(source); 3137 resolve(source);
3157 assertNoErrors(source); 3138 assertNoErrors(source);
3158 verify([source]); 3139 verify([source]);
3159 } 3140 }
3160 3141
3161 void 3142 void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcr etes_method() {
3162 test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcre tes_method() {
3163 Source source = addSource(r''' 3143 Source source = addSource(r'''
3164 class A { 3144 class A {
3165 m(p) {} 3145 m(p) {}
3166 } 3146 }
3167 abstract class B extends A { 3147 abstract class B extends A {
3168 m(p); 3148 m(p);
3169 } 3149 }
3170 class C extends B {}'''); 3150 class C extends B {}''');
3171 resolve(source); 3151 resolve(source);
3172 assertNoErrors(source); 3152 assertNoErrors(source);
3173 verify([source]); 3153 verify([source]);
3174 } 3154 }
3175 3155
3176 void 3156 void test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcr etes_setter() {
3177 test_nonAbstractClassInheritsAbstractMemberOne_abstractsDontOverrideConcre tes_setter() {
3178 Source source = addSource(r''' 3157 Source source = addSource(r'''
3179 class A { 3158 class A {
3180 set s(v) {} 3159 set s(v) {}
3181 } 3160 }
3182 abstract class B extends A { 3161 abstract class B extends A {
3183 set s(v); 3162 set s(v);
3184 } 3163 }
3185 class C extends B {}'''); 3164 class C extends B {}''');
3186 resolve(source); 3165 resolve(source);
3187 assertNoErrors(source); 3166 assertNoErrors(source);
3188 verify([source]); 3167 verify([source]);
3189 } 3168 }
3190 3169
3191 void 3170 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() {
3192 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() {
3193 // 15979 3171 // 15979
3194 Source source = addSource(r''' 3172 Source source = addSource(r'''
3195 abstract class M {} 3173 abstract class M {}
3196 abstract class A {} 3174 abstract class A {}
3197 abstract class I { 3175 abstract class I {
3198 m(); 3176 m();
3199 } 3177 }
3200 abstract class B = A with M implements I;'''); 3178 abstract class B = A with M implements I;''');
3201 resolve(source); 3179 resolve(source);
3202 assertNoErrors(source); 3180 assertNoErrors(source);
3203 verify([source]); 3181 verify([source]);
3204 } 3182 }
3205 3183
3206 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() { 3184 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() {
3207 // 15979 3185 // 15979
3208 Source source = addSource(r''' 3186 Source source = addSource(r'''
3209 abstract class M { 3187 abstract class M {
3210 m(); 3188 m();
3211 } 3189 }
3212 abstract class A {} 3190 abstract class A {}
3213 abstract class B = A with M;'''); 3191 abstract class B = A with M;''');
3214 resolve(source); 3192 resolve(source);
3215 assertNoErrors(source); 3193 assertNoErrors(source);
3216 verify([source]); 3194 verify([source]);
3217 } 3195 }
3218 3196
3219 void 3197 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass( ) {
3220 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() {
3221 // 15979 3198 // 15979
3222 Source source = addSource(r''' 3199 Source source = addSource(r'''
3223 class M {} 3200 class M {}
3224 abstract class A { 3201 abstract class A {
3225 m(); 3202 m();
3226 } 3203 }
3227 abstract class B = A with M;'''); 3204 abstract class B = A with M;''');
3228 resolve(source); 3205 resolve(source);
3229 assertNoErrors(source); 3206 assertNoErrors(source);
3230 verify([source]); 3207 verify([source]);
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
4327 } 4304 }
4328 class _InvertedCodec<T2, S2> extends Codec<T2, S2> { 4305 class _InvertedCodec<T2, S2> extends Codec<T2, S2> {
4329 _InvertedCodec(Codec<S2, T2> codec); 4306 _InvertedCodec(Codec<S2, T2> codec);
4330 }'''); 4307 }''');
4331 resolve(source); 4308 resolve(source);
4332 assertNoErrors(source); 4309 assertNoErrors(source);
4333 verify([source]); 4310 verify([source]);
4334 } 4311 }
4335 4312
4336 void test_sharedDeferredPrefix() { 4313 void test_sharedDeferredPrefix() {
4337 resolveWithErrors(<String>[r''' 4314 resolveWithErrors(<String>[
4315 r'''
4338 library lib1; 4316 library lib1;
4339 f1() {}''', r''' 4317 f1() {}''',
4318 r'''
4340 library lib2; 4319 library lib2;
4341 f2() {}''', r''' 4320 f2() {}''',
4321 r'''
4342 library lib3; 4322 library lib3;
4343 f3() {}''', r''' 4323 f3() {}''',
4324 r'''
4344 library root; 4325 library root;
4345 import 'lib1.dart' deferred as lib1; 4326 import 'lib1.dart' deferred as lib1;
4346 import 'lib2.dart' as lib; 4327 import 'lib2.dart' as lib;
4347 import 'lib3.dart' as lib; 4328 import 'lib3.dart' as lib;
4348 main() { lib1.f1(); lib.f2(); lib.f3(); }'''], <ErrorCode>[]); 4329 main() { lib1.f1(); lib.f2(); lib.f3(); }'''
4330 ], <ErrorCode>[]);
4349 } 4331 }
4350 4332
4351 void test_staticAccessToInstanceMember_annotation() { 4333 void test_staticAccessToInstanceMember_annotation() {
4352 Source source = addSource(r''' 4334 Source source = addSource(r'''
4353 class A { 4335 class A {
4354 const A.name(); 4336 const A.name();
4355 } 4337 }
4356 @A.name() 4338 @A.name()
4357 main() { 4339 main() {
4358 }'''); 4340 }''');
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
4482 void test_typePromotion_booleanAnd_useInRight() { 4464 void test_typePromotion_booleanAnd_useInRight() {
4483 Source source = addSource(r''' 4465 Source source = addSource(r'''
4484 main(Object p) { 4466 main(Object p) {
4485 p is String && p.length != 0; 4467 p is String && p.length != 0;
4486 }'''); 4468 }''');
4487 resolve(source); 4469 resolve(source);
4488 assertNoErrors(source); 4470 assertNoErrors(source);
4489 verify([source]); 4471 verify([source]);
4490 } 4472 }
4491 4473
4492 void 4474 void test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignm ent() {
4493 test_typePromotion_booleanAnd_useInRight_accessedInClosureRight_noAssignme nt() {
4494 Source source = addSource(r''' 4475 Source source = addSource(r'''
4495 callMe(f()) { f(); } 4476 callMe(f()) { f(); }
4496 main(Object p) { 4477 main(Object p) {
4497 (p is String) && callMe(() { p.length; }); 4478 (p is String) && callMe(() { p.length; });
4498 }'''); 4479 }''');
4499 resolve(source); 4480 resolve(source);
4500 assertNoErrors(source); 4481 assertNoErrors(source);
4501 verify([source]); 4482 verify([source]);
4502 } 4483 }
4503 4484
(...skipping 16 matching lines...) Expand all
4520 void test_typePromotion_conditional_useInThen() { 4501 void test_typePromotion_conditional_useInThen() {
4521 Source source = addSource(r''' 4502 Source source = addSource(r'''
4522 main(Object p) { 4503 main(Object p) {
4523 p is String ? p.length : 0; 4504 p is String ? p.length : 0;
4524 }'''); 4505 }''');
4525 resolve(source); 4506 resolve(source);
4526 assertNoErrors(source); 4507 assertNoErrors(source);
4527 verify([source]); 4508 verify([source]);
4528 } 4509 }
4529 4510
4530 void 4511 void test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment() {
4531 test_typePromotion_conditional_useInThen_accessedInClosure_noAssignment() {
4532 Source source = addSource(r''' 4512 Source source = addSource(r'''
4533 callMe(f()) { f(); } 4513 callMe(f()) { f(); }
4534 main(Object p) { 4514 main(Object p) {
4535 p is String ? callMe(() { p.length; }) : 0; 4515 p is String ? callMe(() { p.length; }) : 0;
4536 }'''); 4516 }''');
4537 resolve(source); 4517 resolve(source);
4538 assertNoErrors(source); 4518 assertNoErrors(source);
4539 verify([source]); 4519 verify([source]);
4540 } 4520 }
4541 4521
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
5366 void test_yieldInNonGenerator_syncStar() { 5346 void test_yieldInNonGenerator_syncStar() {
5367 Source source = addSource(r''' 5347 Source source = addSource(r'''
5368 f() sync* { 5348 f() sync* {
5369 yield 0; 5349 yield 0;
5370 }'''); 5350 }''');
5371 resolve(source); 5351 resolve(source);
5372 assertNoErrors(source); 5352 assertNoErrors(source);
5373 verify([source]); 5353 verify([source]);
5374 } 5354 }
5375 5355
5376 void _check_wrongNumberOfParametersForOperator(String name, 5356 void _check_wrongNumberOfParametersForOperator(
5377 String parameters) { 5357 String name, String parameters) {
5378 Source source = addSource(""" 5358 Source source = addSource("""
5379 class A { 5359 class A {
5380 operator $name($parameters) {} 5360 operator $name($parameters) {}
5381 }"""); 5361 }""");
5382 resolve(source); 5362 resolve(source);
5383 assertNoErrors(source); 5363 assertNoErrors(source);
5384 verify([source]); 5364 verify([source]);
5385 reset(); 5365 reset();
5386 } 5366 }
5387 5367
5388 void _check_wrongNumberOfParametersForOperator1(String name) { 5368 void _check_wrongNumberOfParametersForOperator1(String name) {
5389 _check_wrongNumberOfParametersForOperator(name, "a"); 5369 _check_wrongNumberOfParametersForOperator(name, "a");
5390 } 5370 }
5391 } 5371 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/incremental_scanner_test.dart ('k') | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698