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

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

Issue 829133007: Enable enum and deferred import support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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.compile_time_error_code_test; 5 library engine.compile_time_error_code_test;
6 6
7 import 'package:analyzer/src/generated/error.dart'; 7 import 'package:analyzer/src/generated/error.dart';
8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; 8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
9 import 'package:analyzer/src/generated/source_io.dart'; 9 import 'package:analyzer/src/generated/source_io.dart';
10 import 'package:unittest/unittest.dart' as _ut; 10 import 'package:unittest/unittest.dart' as _ut;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 Source source = addSource(r''' 187 Source source = addSource(r'''
188 f() { 188 f() {
189 yield 0; 189 yield 0;
190 }'''); 190 }''');
191 resolve(source); 191 resolve(source);
192 assertErrors(source, [CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR]); 192 assertErrors(source, [CompileTimeErrorCode.YIELD_EACH_IN_NON_GENERATOR]);
193 verify([source]); 193 verify([source]);
194 } 194 }
195 195
196 void test_accessPrivateEnumField() { 196 void test_accessPrivateEnumField() {
197 resetWithEnum();
198 Source source = addSource(r''' 197 Source source = addSource(r'''
199 enum E { ONE } 198 enum E { ONE }
200 String name(E e) { 199 String name(E e) {
201 return e._name; 200 return e._name;
202 }'''); 201 }''');
203 resolve(source); 202 resolve(source);
204 assertErrors(source, [CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD]); 203 assertErrors(source, [CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD]);
205 // Cannot verify because "_name" cannot be resolved. 204 // Cannot verify because "_name" cannot be resolved.
206 } 205 }
207 206
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 const A(); 631 const A();
633 }'''); 632 }''');
634 resolve(source); 633 resolve(source);
635 assertErrors( 634 assertErrors(
636 source, 635 source,
637 [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]); 636 [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD]);
638 verify([source]); 637 verify([source]);
639 } 638 }
640 639
641 void test_constDeferredClass() { 640 void test_constDeferredClass() {
642 resolveWithAndWithoutExperimental(<String>[r''' 641 resolveWithErrors(<String>[r'''
643 library lib1; 642 library lib1;
644 class A { 643 class A {
645 const A(); 644 const A();
646 }''', r''' 645 }''', r'''
647 library root; 646 library root;
648 import 'lib1.dart' deferred as a; 647 import 'lib1.dart' deferred as a;
649 main() { 648 main() {
650 const a.A(); 649 const a.A();
651 }'''], 650 }'''],
652 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
653 <ErrorCode>[CompileTimeErrorCode.CONST_DEFERRED_CLASS]); 651 <ErrorCode>[CompileTimeErrorCode.CONST_DEFERRED_CLASS]);
654 } 652 }
655 653
656 void test_constDeferredClass_namedConstructor() { 654 void test_constDeferredClass_namedConstructor() {
657 resolveWithAndWithoutExperimental(<String>[r''' 655 resolveWithErrors(<String>[r'''
658 library lib1; 656 library lib1;
659 class A { 657 class A {
660 const A.b(); 658 const A.b();
661 }''', r''' 659 }''', r'''
662 library root; 660 library root;
663 import 'lib1.dart' deferred as a; 661 import 'lib1.dart' deferred as a;
664 main() { 662 main() {
665 const a.A.b(); 663 const a.A.b();
666 }'''], 664 }'''],
667 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
668 <ErrorCode>[CompileTimeErrorCode.CONST_DEFERRED_CLASS]); 665 <ErrorCode>[CompileTimeErrorCode.CONST_DEFERRED_CLASS]);
669 } 666 }
670 667
671 void test_constEval_newInstance_constConstructor() { 668 void test_constEval_newInstance_constConstructor() {
672 Source source = addSource(r''' 669 Source source = addSource(r'''
673 class A { 670 class A {
674 const A(); 671 const A();
675 } 672 }
676 const a = new A();'''); 673 const a = new A();''');
677 resolve(source); 674 resolve(source);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 void test_constInitializedWithNonConstValue_missingConstInMapLiteral() { 856 void test_constInitializedWithNonConstValue_missingConstInMapLiteral() {
860 Source source = addSource("const Map M = {'a' : 0};"); 857 Source source = addSource("const Map M = {'a' : 0};");
861 resolve(source); 858 resolve(source);
862 assertErrors( 859 assertErrors(
863 source, 860 source,
864 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]); 861 [CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE]);
865 verify([source]); 862 verify([source]);
866 } 863 }
867 864
868 void test_constInitializedWithNonConstValueFromDeferredClass() { 865 void test_constInitializedWithNonConstValueFromDeferredClass() {
869 resolveWithAndWithoutExperimental(<String>[r''' 866 resolveWithErrors(<String>[r'''
870 library lib1; 867 library lib1;
871 const V = 1;''', r''' 868 const V = 1;''', r'''
872 library root; 869 library root;
873 import 'lib1.dart' deferred as a; 870 import 'lib1.dart' deferred as a;
874 const B = a.V;'''], 871 const B = a.V;'''],
875 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
876 <ErrorCode>[ 872 <ErrorCode>[
877 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FRO M_DEFERRED_LIBRARY]); 873 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FRO M_DEFERRED_LIBRARY]);
878 } 874 }
879 875
880 void test_constInitializedWithNonConstValueFromDeferredClass_nested() { 876 void test_constInitializedWithNonConstValueFromDeferredClass_nested() {
881 resolveWithAndWithoutExperimental(<String>[r''' 877 resolveWithErrors(<String>[r'''
882 library lib1; 878 library lib1;
883 const V = 1;''', r''' 879 const V = 1;''', r'''
884 library root; 880 library root;
885 import 'lib1.dart' deferred as a; 881 import 'lib1.dart' deferred as a;
886 const B = a.V + 1;'''], 882 const B = a.V + 1;'''],
887 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
888 <ErrorCode>[ 883 <ErrorCode>[
889 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FRO M_DEFERRED_LIBRARY]); 884 CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FRO M_DEFERRED_LIBRARY]);
890 } 885 }
891 886
892 void test_constInstanceField() { 887 void test_constInstanceField() {
893 Source source = addSource(r''' 888 Source source = addSource(r'''
894 class C { 889 class C {
895 const int f = 0; 890 const int f = 0;
896 }'''); 891 }''');
897 resolve(source); 892 resolve(source);
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 Source source = addSource(r''' 1404 Source source = addSource(r'''
1410 library L; 1405 library L;
1411 export 'lib1.dart';'''); 1406 export 'lib1.dart';''');
1412 addNamedSource("/lib1.dart", "part of lib;"); 1407 addNamedSource("/lib1.dart", "part of lib;");
1413 resolve(source); 1408 resolve(source);
1414 assertErrors(source, [CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]); 1409 assertErrors(source, [CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY]);
1415 verify([source]); 1410 verify([source]);
1416 } 1411 }
1417 1412
1418 void test_extendsDeferredClass() { 1413 void test_extendsDeferredClass() {
1419 resolveWithAndWithoutExperimental(<String>[r''' 1414 resolveWithErrors(<String>[r'''
1420 library lib1; 1415 library lib1;
1421 class A {}''', r''' 1416 class A {}''', r'''
1422 library root; 1417 library root;
1423 import 'lib1.dart' deferred as a; 1418 import 'lib1.dart' deferred as a;
1424 class B extends a.A {}'''], 1419 class B extends a.A {}'''],
1425 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
1426 <ErrorCode>[CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS]); 1420 <ErrorCode>[CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS]);
1427 } 1421 }
1428 1422
1429 void test_extendsDeferredClass_classTypeAlias() { 1423 void test_extendsDeferredClass_classTypeAlias() {
1430 resolveWithAndWithoutExperimental(<String>[r''' 1424 resolveWithErrors(<String>[r'''
1431 library lib1; 1425 library lib1;
1432 class A {}''', r''' 1426 class A {}''', r'''
1433 library root; 1427 library root;
1434 import 'lib1.dart' deferred as a; 1428 import 'lib1.dart' deferred as a;
1435 class M {} 1429 class M {}
1436 class C = a.A with M;'''], 1430 class C = a.A with M;'''],
1437 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
1438 <ErrorCode>[CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS]); 1431 <ErrorCode>[CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS]);
1439 } 1432 }
1440 1433
1441 void test_extendsDisallowedClass_class_bool() { 1434 void test_extendsDisallowedClass_class_bool() {
1442 Source source = addSource("class A extends bool {}"); 1435 Source source = addSource("class A extends bool {}");
1443 resolve(source); 1436 resolve(source);
1444 assertErrors( 1437 assertErrors(
1445 source, 1438 source,
1446 [ 1439 [
1447 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, 1440 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 resolve(source); 1557 resolve(source);
1565 assertErrors( 1558 assertErrors(
1566 source, 1559 source,
1567 [ 1560 [
1568 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS, 1561 CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS,
1569 CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]); 1562 CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS]);
1570 verify([source]); 1563 verify([source]);
1571 } 1564 }
1572 1565
1573 void test_extendsEnum() { 1566 void test_extendsEnum() {
1574 resetWithEnum();
1575 Source source = addSource(r''' 1567 Source source = addSource(r'''
1576 enum E { ONE } 1568 enum E { ONE }
1577 class A extends E {}'''); 1569 class A extends E {}''');
1578 resolve(source); 1570 resolve(source);
1579 assertErrors(source, [CompileTimeErrorCode.EXTENDS_ENUM]); 1571 assertErrors(source, [CompileTimeErrorCode.EXTENDS_ENUM]);
1580 verify([source]); 1572 verify([source]);
1581 } 1573 }
1582 1574
1583 void test_extendsNonClass_class() { 1575 void test_extendsNonClass_class() {
1584 Source source = addSource(r''' 1576 Source source = addSource(r'''
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1874 get x => 0; 1866 get x => 0;
1875 }'''); 1867 }''');
1876 resolve(source); 1868 resolve(source);
1877 assertErrors( 1869 assertErrors(
1878 source, 1870 source,
1879 [CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]); 1871 [CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]);
1880 verify([source]); 1872 verify([source]);
1881 } 1873 }
1882 1874
1883 void test_implementsDeferredClass() { 1875 void test_implementsDeferredClass() {
1884 resolveWithAndWithoutExperimental(<String>[r''' 1876 resolveWithErrors(<String>[r'''
1885 library lib1; 1877 library lib1;
1886 class A {}''', r''' 1878 class A {}''', r'''
1887 library root; 1879 library root;
1888 import 'lib1.dart' deferred as a; 1880 import 'lib1.dart' deferred as a;
1889 class B implements a.A {}'''], 1881 class B implements a.A {}'''],
1890 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
1891 <ErrorCode>[CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS]); 1882 <ErrorCode>[CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS]);
1892 } 1883 }
1893 1884
1894 void test_implementsDeferredClass_classTypeAlias() { 1885 void test_implementsDeferredClass_classTypeAlias() {
1895 resolveWithAndWithoutExperimental(<String>[r''' 1886 resolveWithErrors(<String>[r'''
1896 library lib1; 1887 library lib1;
1897 class A {}''', r''' 1888 class A {}''', r'''
1898 library root; 1889 library root;
1899 import 'lib1.dart' deferred as a; 1890 import 'lib1.dart' deferred as a;
1900 class B {} 1891 class B {}
1901 class M {} 1892 class M {}
1902 class C = B with M implements a.A;'''], 1893 class C = B with M implements a.A;'''],
1903 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
1904 <ErrorCode>[CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS]); 1894 <ErrorCode>[CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS]);
1905 } 1895 }
1906 1896
1907 void test_implementsDisallowedClass_class_bool() { 1897 void test_implementsDisallowedClass_class_bool() {
1908 Source source = addSource("class A implements bool {}"); 1898 Source source = addSource("class A implements bool {}");
1909 resolve(source); 1899 resolve(source);
1910 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]); 1900 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS]);
1911 verify([source]); 1901 verify([source]);
1912 } 1902 }
1913 1903
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 } 2022 }
2033 2023
2034 void test_implementsDynamic() { 2024 void test_implementsDynamic() {
2035 Source source = addSource("class A implements dynamic {}"); 2025 Source source = addSource("class A implements dynamic {}");
2036 resolve(source); 2026 resolve(source);
2037 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]); 2027 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_DYNAMIC]);
2038 verify([source]); 2028 verify([source]);
2039 } 2029 }
2040 2030
2041 void test_implementsEnum() { 2031 void test_implementsEnum() {
2042 resetWithEnum();
2043 Source source = addSource(r''' 2032 Source source = addSource(r'''
2044 enum E { ONE } 2033 enum E { ONE }
2045 class A implements E {}'''); 2034 class A implements E {}''');
2046 resolve(source); 2035 resolve(source);
2047 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_ENUM]); 2036 assertErrors(source, [CompileTimeErrorCode.IMPLEMENTS_ENUM]);
2048 verify([source]); 2037 verify([source]);
2049 } 2038 }
2050 2039
2051 void test_implementsNonClass_class() { 2040 void test_implementsNonClass_class() {
2052 Source source = addSource(r''' 2041 Source source = addSource(r'''
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 } 2463 }
2475 }'''); 2464 }''');
2476 resolve(source); 2465 resolve(source);
2477 assertErrors( 2466 assertErrors(
2478 source, 2467 source,
2479 [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]); 2468 [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC]);
2480 verify([source]); 2469 verify([source]);
2481 } 2470 }
2482 2471
2483 void test_instantiateEnum_const() { 2472 void test_instantiateEnum_const() {
2484 resetWithEnum();
2485 Source source = addSource(r''' 2473 Source source = addSource(r'''
2486 enum E { ONE } 2474 enum E { ONE }
2487 E e(String name) { 2475 E e(String name) {
2488 return const E(); 2476 return const E();
2489 }'''); 2477 }''');
2490 resolve(source); 2478 resolve(source);
2491 assertErrors(source, [CompileTimeErrorCode.INSTANTIATE_ENUM]); 2479 assertErrors(source, [CompileTimeErrorCode.INSTANTIATE_ENUM]);
2492 verify([source]); 2480 verify([source]);
2493 } 2481 }
2494 2482
2495 void test_instantiateEnum_new() { 2483 void test_instantiateEnum_new() {
2496 resetWithEnum();
2497 Source source = addSource(r''' 2484 Source source = addSource(r'''
2498 enum E { ONE } 2485 enum E { ONE }
2499 E e(String name) { 2486 E e(String name) {
2500 return new E(); 2487 return new E();
2501 }'''); 2488 }''');
2502 resolve(source); 2489 resolve(source);
2503 assertErrors(source, [CompileTimeErrorCode.INSTANTIATE_ENUM]); 2490 assertErrors(source, [CompileTimeErrorCode.INSTANTIATE_ENUM]);
2504 verify([source]); 2491 verify([source]);
2505 } 2492 }
2506 2493
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 @foo 2613 @foo
2627 class A { 2614 class A {
2628 static const foo = null; 2615 static const foo = null;
2629 }'''); 2616 }''');
2630 resolve(source); 2617 resolve(source);
2631 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]); 2618 assertErrors(source, [CompileTimeErrorCode.INVALID_ANNOTATION]);
2632 } 2619 }
2633 2620
2634 void test_invalidAnnotationFromDeferredLibrary() { 2621 void test_invalidAnnotationFromDeferredLibrary() {
2635 // See test_invalidAnnotation_notConstantVariable 2622 // See test_invalidAnnotation_notConstantVariable
2636 resolveWithAndWithoutExperimental(<String>[r''' 2623 resolveWithErrors(<String>[r'''
2637 library lib1; 2624 library lib1;
2638 class V { const V(); } 2625 class V { const V(); }
2639 const v = const V();''', r''' 2626 const v = const V();''', r'''
2640 library root; 2627 library root;
2641 import 'lib1.dart' deferred as a; 2628 import 'lib1.dart' deferred as a;
2642 @a.v main () {}'''], 2629 @a.v main () {}'''],
2643 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
2644 <ErrorCode>[CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBR ARY]); 2630 <ErrorCode>[CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBR ARY]);
2645 } 2631 }
2646 2632
2647 void test_invalidAnnotationFromDeferredLibrary_constructor() { 2633 void test_invalidAnnotationFromDeferredLibrary_constructor() {
2648 // See test_invalidAnnotation_notConstantVariable 2634 // See test_invalidAnnotation_notConstantVariable
2649 resolveWithAndWithoutExperimental(<String>[r''' 2635 resolveWithErrors(<String>[r'''
2650 library lib1; 2636 library lib1;
2651 class C { const C(); }''', r''' 2637 class C { const C(); }''', r'''
2652 library root; 2638 library root;
2653 import 'lib1.dart' deferred as a; 2639 import 'lib1.dart' deferred as a;
2654 @a.C() main () {}'''], 2640 @a.C() main () {}'''],
2655 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
2656 <ErrorCode>[CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBR ARY]); 2641 <ErrorCode>[CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBR ARY]);
2657 } 2642 }
2658 2643
2659 void test_invalidAnnotationFromDeferredLibrary_namedConstructor() { 2644 void test_invalidAnnotationFromDeferredLibrary_namedConstructor() {
2660 // See test_invalidAnnotation_notConstantVariable 2645 // See test_invalidAnnotation_notConstantVariable
2661 resolveWithAndWithoutExperimental(<String>[r''' 2646 resolveWithErrors(<String>[r'''
2662 library lib1; 2647 library lib1;
2663 class C { const C.name(); }''', r''' 2648 class C { const C.name(); }''', r'''
2664 library root; 2649 library root;
2665 import 'lib1.dart' deferred as a; 2650 import 'lib1.dart' deferred as a;
2666 @a.C.name() main () {}'''], 2651 @a.C.name() main () {}'''],
2667 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
2668 <ErrorCode>[CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBR ARY]); 2652 <ErrorCode>[CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBR ARY]);
2669 } 2653 }
2670 2654
2671 void test_invalidConstructorName_notEnclosingClassName_defined() { 2655 void test_invalidConstructorName_notEnclosingClassName_defined() {
2672 Source source = addSource(r''' 2656 Source source = addSource(r'''
2673 class A { 2657 class A {
2674 B() : super(); 2658 B() : super();
2675 } 2659 }
2676 class B {}'''); 2660 class B {}''');
2677 resolve(source); 2661 resolve(source);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 x(y) {} 3031 x(y) {}
3048 }'''); 3032 }''');
3049 resolve(source); 3033 resolve(source);
3050 assertErrors( 3034 assertErrors(
3051 source, 3035 source,
3052 [CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]); 3036 [CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]);
3053 verify([source]); 3037 verify([source]);
3054 } 3038 }
3055 3039
3056 void test_missingEnumConstantInSwitch() { 3040 void test_missingEnumConstantInSwitch() {
3057 resetWithEnum();
3058 Source source = addSource(r''' 3041 Source source = addSource(r'''
3059 enum E { ONE, TWO, THREE, FOUR } 3042 enum E { ONE, TWO, THREE, FOUR }
3060 bool odd(E e) { 3043 bool odd(E e) {
3061 switch (e) { 3044 switch (e) {
3062 case E.ONE: 3045 case E.ONE:
3063 case E.THREE: return true; 3046 case E.THREE: return true;
3064 } 3047 }
3065 return false; 3048 return false;
3066 }'''); 3049 }''');
3067 resolve(source); 3050 resolve(source);
(...skipping 21 matching lines...) Expand all
3089 class A { 3072 class A {
3090 A() {} 3073 A() {}
3091 } 3074 }
3092 class B = Object with A;'''); 3075 class B = Object with A;''');
3093 resolve(source); 3076 resolve(source);
3094 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); 3077 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
3095 verify([source]); 3078 verify([source]);
3096 } 3079 }
3097 3080
3098 void test_mixinDeferredClass() { 3081 void test_mixinDeferredClass() {
3099 resolveWithAndWithoutExperimental(<String>[r''' 3082 resolveWithErrors(<String>[r'''
3100 library lib1; 3083 library lib1;
3101 class A {}''', r''' 3084 class A {}''', r'''
3102 library root; 3085 library root;
3103 import 'lib1.dart' deferred as a; 3086 import 'lib1.dart' deferred as a;
3104 class B extends Object with a.A {}'''], 3087 class B extends Object with a.A {}'''],
3105 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
3106 <ErrorCode>[CompileTimeErrorCode.MIXIN_DEFERRED_CLASS]); 3088 <ErrorCode>[CompileTimeErrorCode.MIXIN_DEFERRED_CLASS]);
3107 } 3089 }
3108 3090
3109 void test_mixinDeferredClass_classTypeAlias() { 3091 void test_mixinDeferredClass_classTypeAlias() {
3110 resolveWithAndWithoutExperimental(<String>[r''' 3092 resolveWithErrors(<String>[r'''
3111 library lib1; 3093 library lib1;
3112 class A {}''', r''' 3094 class A {}''', r'''
3113 library root; 3095 library root;
3114 import 'lib1.dart' deferred as a; 3096 import 'lib1.dart' deferred as a;
3115 class B {} 3097 class B {}
3116 class C = B with a.A;'''], 3098 class C = B with a.A;'''],
3117 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
3118 <ErrorCode>[CompileTimeErrorCode.MIXIN_DEFERRED_CLASS]); 3099 <ErrorCode>[CompileTimeErrorCode.MIXIN_DEFERRED_CLASS]);
3119 } 3100 }
3120 3101
3121 void test_mixinHasNoConstructors_mixinApp() { 3102 void test_mixinHasNoConstructors_mixinApp() {
3122 Source source = addSource(r''' 3103 Source source = addSource(r'''
3123 class B { 3104 class B {
3124 B({x}); 3105 B({x});
3125 } 3106 }
3126 class M {} 3107 class M {}
3127 class C = B with M; 3108 class C = B with M;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 resolve(source); 3329 resolve(source);
3349 assertErrors( 3330 assertErrors(
3350 source, 3331 source,
3351 [ 3332 [
3352 CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS, 3333 CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS,
3353 CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]); 3334 CompileTimeErrorCode.MIXIN_OF_DISALLOWED_CLASS]);
3354 verify([source]); 3335 verify([source]);
3355 } 3336 }
3356 3337
3357 void test_mixinOfEnum() { 3338 void test_mixinOfEnum() {
3358 resetWithEnum();
3359 Source source = addSource(r''' 3339 Source source = addSource(r'''
3360 enum E { ONE } 3340 enum E { ONE }
3361 class A extends Object with E {}'''); 3341 class A extends Object with E {}''');
3362 resolve(source); 3342 resolve(source);
3363 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_ENUM]); 3343 assertErrors(source, [CompileTimeErrorCode.MIXIN_OF_ENUM]);
3364 verify([source]); 3344 verify([source]);
3365 } 3345 }
3366 3346
3367 void test_mixinOfNonClass_class() { 3347 void test_mixinOfNonClass_class() {
3368 Source source = addSource(r''' 3348 Source source = addSource(r'''
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
3835 class A { 3815 class A {
3836 int y; 3816 int y;
3837 m([x = y]) {} 3817 m([x = y]) {}
3838 }'''); 3818 }''');
3839 resolve(source); 3819 resolve(source);
3840 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]); 3820 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE]);
3841 verify([source]); 3821 verify([source]);
3842 } 3822 }
3843 3823
3844 void test_nonConstantDefaultValueFromDeferredLibrary() { 3824 void test_nonConstantDefaultValueFromDeferredLibrary() {
3845 resolveWithAndWithoutExperimental(<String>[r''' 3825 resolveWithErrors(<String>[r'''
3846 library lib1; 3826 library lib1;
3847 const V = 1;''', r''' 3827 const V = 1;''', r'''
3848 library root; 3828 library root;
3849 import 'lib1.dart' deferred as a; 3829 import 'lib1.dart' deferred as a;
3850 f({x : a.V}) {}'''], 3830 f({x : a.V}) {}'''],
3851 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
3852 <ErrorCode>[ 3831 <ErrorCode>[
3853 CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBR ARY]); 3832 CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBR ARY]);
3854 } 3833 }
3855 3834
3856 void test_nonConstantDefaultValueFromDeferredLibrary_nested() { 3835 void test_nonConstantDefaultValueFromDeferredLibrary_nested() {
3857 resolveWithAndWithoutExperimental(<String>[r''' 3836 resolveWithErrors(<String>[r'''
3858 library lib1; 3837 library lib1;
3859 const V = 1;''', r''' 3838 const V = 1;''', r'''
3860 library root; 3839 library root;
3861 import 'lib1.dart' deferred as a; 3840 import 'lib1.dart' deferred as a;
3862 f({x : a.V + 1}) {}'''], 3841 f({x : a.V + 1}) {}'''],
3863 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
3864 <ErrorCode>[ 3842 <ErrorCode>[
3865 CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBR ARY]); 3843 CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBR ARY]);
3866 } 3844 }
3867 3845
3868 void test_nonConstCaseExpression() { 3846 void test_nonConstCaseExpression() {
3869 Source source = addSource(r''' 3847 Source source = addSource(r'''
3870 f(int p, int q) { 3848 f(int p, int q) {
3871 switch (p) { 3849 switch (p) {
3872 case 3 + q: 3850 case 3 + q:
3873 break; 3851 break;
3874 } 3852 }
3875 }'''); 3853 }''');
3876 resolve(source); 3854 resolve(source);
3877 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]); 3855 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION]);
3878 verify([source]); 3856 verify([source]);
3879 } 3857 }
3880 3858
3881 void test_nonConstCaseExpressionFromDeferredLibrary() { 3859 void test_nonConstCaseExpressionFromDeferredLibrary() {
3882 resolveWithAndWithoutExperimental(<String>[r''' 3860 resolveWithErrors(<String>[r'''
3883 library lib1; 3861 library lib1;
3884 const int c = 1;''', r''' 3862 const int c = 1;''', r'''
3885 library root; 3863 library root;
3886 import 'lib1.dart' deferred as a; 3864 import 'lib1.dart' deferred as a;
3887 main (int p) { 3865 main (int p) {
3888 switch (p) { 3866 switch (p) {
3889 case a.c: 3867 case a.c:
3890 break; 3868 break;
3891 } 3869 }
3892 }'''], 3870 }'''],
3893 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
3894 <ErrorCode>[ 3871 <ErrorCode>[
3895 CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LI BRARY]); 3872 CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LI BRARY]);
3896 } 3873 }
3897 3874
3898 void test_nonConstCaseExpressionFromDeferredLibrary_nested() { 3875 void test_nonConstCaseExpressionFromDeferredLibrary_nested() {
3899 resolveWithAndWithoutExperimental(<String>[r''' 3876 resolveWithErrors(<String>[r'''
3900 library lib1; 3877 library lib1;
3901 const int c = 1;''', r''' 3878 const int c = 1;''', r'''
3902 library root; 3879 library root;
3903 import 'lib1.dart' deferred as a; 3880 import 'lib1.dart' deferred as a;
3904 main (int p) { 3881 main (int p) {
3905 switch (p) { 3882 switch (p) {
3906 case a.c + 1: 3883 case a.c + 1:
3907 break; 3884 break;
3908 } 3885 }
3909 }'''], 3886 }'''],
3910 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
3911 <ErrorCode>[ 3887 <ErrorCode>[
3912 CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LI BRARY]); 3888 CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LI BRARY]);
3913 } 3889 }
3914 3890
3915 void test_nonConstListElement() { 3891 void test_nonConstListElement() {
3916 Source source = addSource(r''' 3892 Source source = addSource(r'''
3917 f(a) { 3893 f(a) {
3918 return const [a]; 3894 return const [a];
3919 }'''); 3895 }''');
3920 resolve(source); 3896 resolve(source);
3921 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]); 3897 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT]);
3922 verify([source]); 3898 verify([source]);
3923 } 3899 }
3924 3900
3925 void test_nonConstListElementFromDeferredLibrary() { 3901 void test_nonConstListElementFromDeferredLibrary() {
3926 resolveWithAndWithoutExperimental(<String>[r''' 3902 resolveWithErrors(<String>[r'''
3927 library lib1; 3903 library lib1;
3928 const int c = 1;''', r''' 3904 const int c = 1;''', r'''
3929 library root; 3905 library root;
3930 import 'lib1.dart' deferred as a; 3906 import 'lib1.dart' deferred as a;
3931 f() { 3907 f() {
3932 return const [a.c]; 3908 return const [a.c];
3933 }'''], 3909 }'''],
3934 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
3935 <ErrorCode>[ 3910 <ErrorCode>[
3936 CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRA RY]); 3911 CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRA RY]);
3937 } 3912 }
3938 3913
3939 void test_nonConstListElementFromDeferredLibrary_nested() { 3914 void test_nonConstListElementFromDeferredLibrary_nested() {
3940 resolveWithAndWithoutExperimental(<String>[r''' 3915 resolveWithErrors(<String>[r'''
3941 library lib1; 3916 library lib1;
3942 const int c = 1;''', r''' 3917 const int c = 1;''', r'''
3943 library root; 3918 library root;
3944 import 'lib1.dart' deferred as a; 3919 import 'lib1.dart' deferred as a;
3945 f() { 3920 f() {
3946 return const [a.c + 1]; 3921 return const [a.c + 1];
3947 }'''], 3922 }'''],
3948 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
3949 <ErrorCode>[ 3923 <ErrorCode>[
3950 CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRA RY]); 3924 CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRA RY]);
3951 } 3925 }
3952 3926
3953 void test_nonConstMapAsExpressionStatement_begin() { 3927 void test_nonConstMapAsExpressionStatement_begin() {
3954 Source source = addSource(r''' 3928 Source source = addSource(r'''
3955 f() { 3929 f() {
3956 {'a' : 0, 'b' : 1}.length; 3930 {'a' : 0, 'b' : 1}.length;
3957 }'''); 3931 }''');
3958 resolve(source); 3932 resolve(source);
(...skipping 19 matching lines...) Expand all
3978 Source source = addSource(r''' 3952 Source source = addSource(r'''
3979 f(a) { 3953 f(a) {
3980 return const {a : 0}; 3954 return const {a : 0};
3981 }'''); 3955 }''');
3982 resolve(source); 3956 resolve(source);
3983 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]); 3957 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_KEY]);
3984 verify([source]); 3958 verify([source]);
3985 } 3959 }
3986 3960
3987 void test_nonConstMapKeyFromDeferredLibrary() { 3961 void test_nonConstMapKeyFromDeferredLibrary() {
3988 resolveWithAndWithoutExperimental(<String>[r''' 3962 resolveWithErrors(<String>[r'''
3989 library lib1; 3963 library lib1;
3990 const int c = 1;''', r''' 3964 const int c = 1;''', r'''
3991 library root; 3965 library root;
3992 import 'lib1.dart' deferred as a; 3966 import 'lib1.dart' deferred as a;
3993 f() { 3967 f() {
3994 return const {a.c : 0}; 3968 return const {a.c : 0};
3995 }'''], 3969 }'''],
3996 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
3997 <ErrorCode>[CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LI BRARY]); 3970 <ErrorCode>[CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LI BRARY]);
3998 } 3971 }
3999 3972
4000 void test_nonConstMapKeyFromDeferredLibrary_nested() { 3973 void test_nonConstMapKeyFromDeferredLibrary_nested() {
4001 resolveWithAndWithoutExperimental(<String>[r''' 3974 resolveWithErrors(<String>[r'''
4002 library lib1; 3975 library lib1;
4003 const int c = 1;''', r''' 3976 const int c = 1;''', r'''
4004 library root; 3977 library root;
4005 import 'lib1.dart' deferred as a; 3978 import 'lib1.dart' deferred as a;
4006 f() { 3979 f() {
4007 return const {a.c + 1 : 0}; 3980 return const {a.c + 1 : 0};
4008 }'''], 3981 }'''],
4009 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
4010 <ErrorCode>[CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LI BRARY]); 3982 <ErrorCode>[CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LI BRARY]);
4011 } 3983 }
4012 3984
4013 void test_nonConstMapValue() { 3985 void test_nonConstMapValue() {
4014 Source source = addSource(r''' 3986 Source source = addSource(r'''
4015 f(a) { 3987 f(a) {
4016 return const {'a' : a}; 3988 return const {'a' : a};
4017 }'''); 3989 }''');
4018 resolve(source); 3990 resolve(source);
4019 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]); 3991 assertErrors(source, [CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE]);
4020 verify([source]); 3992 verify([source]);
4021 } 3993 }
4022 3994
4023 void test_nonConstMapValueFromDeferredLibrary() { 3995 void test_nonConstMapValueFromDeferredLibrary() {
4024 resolveWithAndWithoutExperimental(<String>[r''' 3996 resolveWithErrors(<String>[r'''
4025 library lib1; 3997 library lib1;
4026 const int c = 1;''', r''' 3998 const int c = 1;''', r'''
4027 library root; 3999 library root;
4028 import 'lib1.dart' deferred as a; 4000 import 'lib1.dart' deferred as a;
4029 f() { 4001 f() {
4030 return const {'a' : a.c}; 4002 return const {'a' : a.c};
4031 }'''], 4003 }'''],
4032 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
4033 <ErrorCode>[CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_ LIBRARY]); 4004 <ErrorCode>[CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_ LIBRARY]);
4034 } 4005 }
4035 4006
4036 void test_nonConstMapValueFromDeferredLibrary_nested() { 4007 void test_nonConstMapValueFromDeferredLibrary_nested() {
4037 resolveWithAndWithoutExperimental(<String>[r''' 4008 resolveWithErrors(<String>[r'''
4038 library lib1; 4009 library lib1;
4039 const int c = 1;''', r''' 4010 const int c = 1;''', r'''
4040 library root; 4011 library root;
4041 import 'lib1.dart' deferred as a; 4012 import 'lib1.dart' deferred as a;
4042 f() { 4013 f() {
4043 return const {'a' : a.c + 1}; 4014 return const {'a' : a.c + 1};
4044 }'''], 4015 }'''],
4045 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
4046 <ErrorCode>[CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_ LIBRARY]); 4016 <ErrorCode>[CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_ LIBRARY]);
4047 } 4017 }
4048 4018
4049 void test_nonConstValueInInitializer_binary_notBool_left() { 4019 void test_nonConstValueInInitializer_binary_notBool_left() {
4050 Source source = addSource(r''' 4020 Source source = addSource(r'''
4051 class A { 4021 class A {
4052 final bool a; 4022 final bool a;
4053 const A(String p) : a = p && true; 4023 const A(String p) : a = p && true;
4054 }'''); 4024 }''');
4055 resolve(source); 4025 resolve(source);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4161 const B() : super(C); 4131 const B() : super(C);
4162 }'''); 4132 }''');
4163 resolve(source); 4133 resolve(source);
4164 assertErrors( 4134 assertErrors(
4165 source, 4135 source,
4166 [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]); 4136 [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
4167 verify([source]); 4137 verify([source]);
4168 } 4138 }
4169 4139
4170 void test_nonConstValueInInitializerFromDeferredLibrary_field() { 4140 void test_nonConstValueInInitializerFromDeferredLibrary_field() {
4171 resolveWithAndWithoutExperimental(<String>[r''' 4141 resolveWithErrors(<String>[r'''
4172 library lib1; 4142 library lib1;
4173 const int c = 1;''', r''' 4143 const int c = 1;''', r'''
4174 library root; 4144 library root;
4175 import 'lib1.dart' deferred as a; 4145 import 'lib1.dart' deferred as a;
4176 class A { 4146 class A {
4177 final int x; 4147 final int x;
4178 const A() : x = a.c; 4148 const A() : x = a.c;
4179 }'''], 4149 }'''],
4180 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
4181 <ErrorCode>[ 4150 <ErrorCode>[
4182 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERR ED_LIBRARY]); 4151 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERR ED_LIBRARY]);
4183 } 4152 }
4184 4153
4185 void test_nonConstValueInInitializerFromDeferredLibrary_field_nested() { 4154 void test_nonConstValueInInitializerFromDeferredLibrary_field_nested() {
4186 resolveWithAndWithoutExperimental(<String>[r''' 4155 resolveWithErrors(<String>[r'''
4187 library lib1; 4156 library lib1;
4188 const int c = 1;''', r''' 4157 const int c = 1;''', r'''
4189 library root; 4158 library root;
4190 import 'lib1.dart' deferred as a; 4159 import 'lib1.dart' deferred as a;
4191 class A { 4160 class A {
4192 final int x; 4161 final int x;
4193 const A() : x = a.c + 1; 4162 const A() : x = a.c + 1;
4194 }'''], 4163 }'''],
4195 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
4196 <ErrorCode>[ 4164 <ErrorCode>[
4197 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERR ED_LIBRARY]); 4165 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERR ED_LIBRARY]);
4198 } 4166 }
4199 4167
4200 void test_nonConstValueInInitializerFromDeferredLibrary_redirecting() { 4168 void test_nonConstValueInInitializerFromDeferredLibrary_redirecting() {
4201 resolveWithAndWithoutExperimental(<String>[r''' 4169 resolveWithErrors(<String>[r'''
4202 library lib1; 4170 library lib1;
4203 const int c = 1;''', r''' 4171 const int c = 1;''', r'''
4204 library root; 4172 library root;
4205 import 'lib1.dart' deferred as a; 4173 import 'lib1.dart' deferred as a;
4206 class A { 4174 class A {
4207 const A.named(p); 4175 const A.named(p);
4208 const A() : this.named(a.c); 4176 const A() : this.named(a.c);
4209 }'''], 4177 }'''],
4210 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
4211 <ErrorCode>[ 4178 <ErrorCode>[
4212 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERR ED_LIBRARY]); 4179 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERR ED_LIBRARY]);
4213 } 4180 }
4214 4181
4215 void test_nonConstValueInInitializerFromDeferredLibrary_super() { 4182 void test_nonConstValueInInitializerFromDeferredLibrary_super() {
4216 resolveWithAndWithoutExperimental(<String>[r''' 4183 resolveWithErrors(<String>[r'''
4217 library lib1; 4184 library lib1;
4218 const int c = 1;''', r''' 4185 const int c = 1;''', r'''
4219 library root; 4186 library root;
4220 import 'lib1.dart' deferred as a; 4187 import 'lib1.dart' deferred as a;
4221 class A { 4188 class A {
4222 const A(p); 4189 const A(p);
4223 } 4190 }
4224 class B extends A { 4191 class B extends A {
4225 const B() : super(a.c); 4192 const B() : super(a.c);
4226 }'''], 4193 }'''],
4227 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
4228 <ErrorCode>[ 4194 <ErrorCode>[
4229 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERR ED_LIBRARY]); 4195 CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERR ED_LIBRARY]);
4230 } 4196 }
4231 4197
4232 void test_nonGenerativeConstructor_explicit() { 4198 void test_nonGenerativeConstructor_explicit() {
4233 Source source = addSource(r''' 4199 Source source = addSource(r'''
4234 class A { 4200 class A {
4235 factory A.named() {} 4201 factory A.named() {}
4236 } 4202 }
4237 class B extends A { 4203 class B extends A {
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
4863 Source source = addSource(r''' 4829 Source source = addSource(r'''
4864 f() sync* { 4830 f() sync* {
4865 return 0; 4831 return 0;
4866 }'''); 4832 }''');
4867 resolve(source); 4833 resolve(source);
4868 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATOR]); 4834 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATOR]);
4869 verify([source]); 4835 verify([source]);
4870 } 4836 }
4871 4837
4872 void test_sharedDeferredPrefix() { 4838 void test_sharedDeferredPrefix() {
4873 resolveWithAndWithoutExperimental(<String>[r''' 4839 resolveWithErrors(<String>[r'''
4874 library lib1; 4840 library lib1;
4875 f1() {}''', r''' 4841 f1() {}''', r'''
4876 library lib2; 4842 library lib2;
4877 f2() {}''', r''' 4843 f2() {}''', r'''
4878 library root; 4844 library root;
4879 import 'lib1.dart' deferred as lib; 4845 import 'lib1.dart' deferred as lib;
4880 import 'lib2.dart' as lib; 4846 import 'lib2.dart' as lib;
4881 main() { lib.f1(); lib.f2(); }'''], 4847 main() { lib.f1(); lib.f2(); }'''],
4882 <ErrorCode>[ParserErrorCode.DEFERRED_IMPORTS_NOT_SUPPORTED],
4883 <ErrorCode>[CompileTimeErrorCode.SHARED_DEFERRED_PREFIX]); 4848 <ErrorCode>[CompileTimeErrorCode.SHARED_DEFERRED_PREFIX]);
4884 } 4849 }
4885 4850
4886 void test_superInInvalidContext_binaryExpression() { 4851 void test_superInInvalidContext_binaryExpression() {
4887 Source source = addSource("var v = super + 0;"); 4852 Source source = addSource("var v = super + 0;");
4888 resolve(source); 4853 resolve(source);
4889 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]); 4854 assertErrors(source, [CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT]);
4890 // no verify(), 'super.v' is not resolved 4855 // no verify(), 'super.v' is not resolved
4891 } 4856 }
4892 4857
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
5449 [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); 5414 [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]);
5450 verify([source]); 5415 verify([source]);
5451 reset(); 5416 reset();
5452 } 5417 }
5453 5418
5454 void _check_wrongNumberOfParametersForOperator1(String name) { 5419 void _check_wrongNumberOfParametersForOperator1(String name) {
5455 _check_wrongNumberOfParametersForOperator(name, ""); 5420 _check_wrongNumberOfParametersForOperator(name, "");
5456 _check_wrongNumberOfParametersForOperator(name, "a, b"); 5421 _check_wrongNumberOfParametersForOperator(name, "a, b");
5457 } 5422 }
5458 } 5423 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698