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

Side by Side Diff: packages/analyzer/test/generated/static_warning_code_test.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 years, 4 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
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.static_warning_code_test; 5 library analyzer.test.generated.static_warning_code_test;
6 6
7 import 'package:analyzer/src/generated/error.dart'; 7 import 'package:analyzer/error/error.dart';
8 import 'package:analyzer/src/error/codes.dart';
9 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/source_io.dart'; 10 import 'package:analyzer/src/generated/source_io.dart';
11 import 'package:test_reflective_loader/test_reflective_loader.dart';
9 import 'package:unittest/unittest.dart'; 12 import 'package:unittest/unittest.dart';
10 13
11 import '../reflective_tests.dart';
12 import '../utils.dart'; 14 import '../utils.dart';
13 import 'resolver_test.dart'; 15 import 'resolver_test_case.dart';
14 16
15 main() { 17 main() {
16 initializeTestEnvironment(); 18 initializeTestEnvironment();
17 runReflectiveTests(StaticWarningCodeTest); 19 defineReflectiveTests(StaticWarningCodeTest);
18 } 20 }
19 21
20 @reflectiveTest 22 @reflectiveTest
21 class StaticWarningCodeTest extends ResolverTestCase { 23 class StaticWarningCodeTest extends ResolverTestCase {
24 void fail_argumentTypeNotAssignable_tearOff_required() {
25 Source source = addSource(r'''
26 class C {
27 Object/*=T*/ f/*<T>*/(Object/*=T*/ x) => x;
28 }
29 g(C c) {
30 var h = c.f/*<int>*/;
31 print(h('s'));
32 }
33 ''');
34 computeLibrarySourceErrors(source);
35 assertErrors(source, [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
36 verify([source]);
37 }
38
22 void fail_undefinedGetter() { 39 void fail_undefinedGetter() {
23 Source source = addSource(r''' 40 Source source = addSource(r'''
24 '''); 41 ''');
25 computeLibrarySourceErrors(source); 42 computeLibrarySourceErrors(source);
26 assertErrors(source, [StaticWarningCode.UNDEFINED_GETTER]); 43 assertErrors(source, [StaticWarningCode.UNDEFINED_GETTER]);
27 verify([source]); 44 verify([source]);
28 } 45 }
29 46
30 void fail_undefinedIdentifier_commentReference() { 47 void fail_undefinedIdentifier_commentReference() {
31 Source source = addSource(r''' 48 Source source = addSource(r'''
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 Source source = addSource(r''' 974 Source source = addSource(r'''
958 class A { 975 class A {
959 m(); 976 m();
960 }'''); 977 }''');
961 computeLibrarySourceErrors(source); 978 computeLibrarySourceErrors(source);
962 assertErrors( 979 assertErrors(
963 source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]); 980 source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]);
964 verify([source]); 981 verify([source]);
965 } 982 }
966 983
984 void test_concreteClassWithAbstractMember_noSuchMethod_interface() {
985 Source source = addSource(r'''
986 class I {
987 noSuchMethod(v) => '';
988 }
989 class A implements I {
990 m();
991 }''');
992 computeLibrarySourceErrors(source);
993 assertErrors(
994 source, [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER]);
995 verify([source]);
996 }
997
967 void test_conflictingDartImport() { 998 void test_conflictingDartImport() {
968 Source source = addSource(r''' 999 Source source = addSource(r'''
969 import 'lib.dart'; 1000 import 'lib.dart';
970 import 'dart:async'; 1001 import 'dart:async';
971 Future f = null; 1002 Future f = null;
972 Stream s;'''); 1003 Stream s;''');
973 addNamedSource( 1004 addNamedSource(
974 "/lib.dart", 1005 "/lib.dart",
975 r''' 1006 r'''
976 library lib; 1007 library lib;
977 class Future {}'''); 1008 class Future {}''');
978 computeLibrarySourceErrors(source); 1009 computeLibrarySourceErrors(source);
979 assertErrors(source, [StaticWarningCode.CONFLICTING_DART_IMPORT]); 1010 assertErrors(source, [StaticWarningCode.CONFLICTING_DART_IMPORT]);
980 } 1011 }
981 1012
982 void test_conflictingInstanceGetterAndSuperclassMember_declField_direct_setter () { 1013 void
1014 test_conflictingInstanceGetterAndSuperclassMember_declField_direct_setter( ) {
983 Source source = addSource(r''' 1015 Source source = addSource(r'''
984 class A { 1016 class A {
985 static set v(x) {} 1017 static set v(x) {}
986 } 1018 }
987 class B extends A { 1019 class B extends A {
988 var v; 1020 var v;
989 }'''); 1021 }''');
990 computeLibrarySourceErrors(source); 1022 computeLibrarySourceErrors(source);
991 assertErrors(source, 1023 assertErrors(source,
992 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]); 1024 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
993 verify([source]); 1025 verify([source]);
994 } 1026 }
995 1027
996 void test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_gette r() { 1028 void
1029 test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_getter () {
997 Source source = addSource(r''' 1030 Source source = addSource(r'''
998 class A { 1031 class A {
999 static get v => 0; 1032 static get v => 0;
1000 } 1033 }
1001 class B extends A { 1034 class B extends A {
1002 get v => 0; 1035 get v => 0;
1003 }'''); 1036 }''');
1004 computeLibrarySourceErrors(source); 1037 computeLibrarySourceErrors(source);
1005 assertErrors(source, 1038 assertErrors(source,
1006 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]); 1039 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
1007 verify([source]); 1040 verify([source]);
1008 } 1041 }
1009 1042
1010 void test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_metho d() { 1043 void
1044 test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_method () {
1011 Source source = addSource(r''' 1045 Source source = addSource(r'''
1012 class A { 1046 class A {
1013 static v() {} 1047 static v() {}
1014 } 1048 }
1015 class B extends A { 1049 class B extends A {
1016 get v => 0; 1050 get v => 0;
1017 }'''); 1051 }''');
1018 computeLibrarySourceErrors(source); 1052 computeLibrarySourceErrors(source);
1019 assertErrors(source, 1053 assertErrors(source,
1020 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]); 1054 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
1021 verify([source]); 1055 verify([source]);
1022 } 1056 }
1023 1057
1024 void test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_sette r() { 1058 void
1059 test_conflictingInstanceGetterAndSuperclassMember_declGetter_direct_setter () {
1025 Source source = addSource(r''' 1060 Source source = addSource(r'''
1026 class A { 1061 class A {
1027 static set v(x) {} 1062 static set v(x) {}
1028 } 1063 }
1029 class B extends A { 1064 class B extends A {
1030 get v => 0; 1065 get v => 0;
1031 }'''); 1066 }''');
1032 computeLibrarySourceErrors(source); 1067 computeLibrarySourceErrors(source);
1033 assertErrors(source, 1068 assertErrors(source,
1034 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]); 1069 [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER]);
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 void test_mismatchedAccessorTypes_topLevel() { 2333 void test_mismatchedAccessorTypes_topLevel() {
2299 Source source = addSource(r''' 2334 Source source = addSource(r'''
2300 int get g { return 0; } 2335 int get g { return 0; }
2301 set g(String v) {}'''); 2336 set g(String v) {}''');
2302 computeLibrarySourceErrors(source); 2337 computeLibrarySourceErrors(source);
2303 assertErrors( 2338 assertErrors(
2304 source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]); 2339 source, [StaticWarningCode.MISMATCHED_GETTER_AND_SETTER_TYPES]);
2305 verify([source]); 2340 verify([source]);
2306 } 2341 }
2307 2342
2343 void test_missingEnumConstantInSwitch() {
2344 Source source = addSource(r'''
2345 enum E { ONE, TWO, THREE, FOUR }
2346 bool odd(E e) {
2347 switch (e) {
2348 case E.ONE:
2349 case E.THREE: return true;
2350 }
2351 return false;
2352 }''');
2353 computeLibrarySourceErrors(source);
2354 assertErrors(source, [
2355 StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH,
2356 StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH
2357 ]);
2358 verify([source]);
2359 }
2360
2308 void test_mixedReturnTypes_localFunction() { 2361 void test_mixedReturnTypes_localFunction() {
2309 Source source = addSource(r''' 2362 Source source = addSource(r'''
2310 class C { 2363 class C {
2311 m(int x) { 2364 m(int x) {
2312 return (int y) { 2365 return (int y) {
2313 if (y < 0) { 2366 if (y < 0) {
2314 return; 2367 return;
2315 } 2368 }
2316 return 0; 2369 return 0;
2317 }; 2370 };
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 p(); 2537 p();
2485 } 2538 }
2486 class C extends A { 2539 class C extends A {
2487 }'''); 2540 }''');
2488 computeLibrarySourceErrors(source); 2541 computeLibrarySourceErrors(source);
2489 assertErrors(source, 2542 assertErrors(source,
2490 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR]); 2543 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR]);
2491 verify([source]); 2544 verify([source]);
2492 } 2545 }
2493 2546
2494 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() { 2547 void
2548 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_interface() {
2495 // 15979 2549 // 15979
2496 Source source = addSource(r''' 2550 Source source = addSource(r'''
2497 abstract class M {} 2551 abstract class M {}
2498 abstract class A {} 2552 abstract class A {}
2499 abstract class I { 2553 abstract class I {
2500 m(); 2554 m();
2501 } 2555 }
2502 class B = A with M implements I;'''); 2556 class B = A with M implements I;''');
2503 computeLibrarySourceErrors(source); 2557 computeLibrarySourceErrors(source);
2504 assertErrors(source, 2558 assertErrors(source,
2505 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2559 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2506 verify([source]); 2560 verify([source]);
2507 } 2561 }
2508 2562
2509 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() { 2563 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_mixin() {
2510 // 15979 2564 // 15979
2511 Source source = addSource(r''' 2565 Source source = addSource(r'''
2512 abstract class M { 2566 abstract class M {
2513 m(); 2567 m();
2514 } 2568 }
2515 abstract class A {} 2569 abstract class A {}
2516 class B = A with M;'''); 2570 class B = A with M;''');
2517 computeLibrarySourceErrors(source); 2571 computeLibrarySourceErrors(source);
2518 assertErrors(source, 2572 assertErrors(source,
2519 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2573 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2520 verify([source]); 2574 verify([source]);
2521 } 2575 }
2522 2576
2523 void test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass( ) { 2577 void
2578 test_nonAbstractClassInheritsAbstractMemberOne_classTypeAlias_superclass() {
2524 // 15979 2579 // 15979
2525 Source source = addSource(r''' 2580 Source source = addSource(r'''
2526 class M {} 2581 class M {}
2527 abstract class A { 2582 abstract class A {
2528 m(); 2583 m();
2529 } 2584 }
2530 class B = A with M;'''); 2585 class B = A with M;''');
2531 computeLibrarySourceErrors(source); 2586 computeLibrarySourceErrors(source);
2532 assertErrors(source, 2587 assertErrors(source,
2533 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2588 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2534 verify([source]); 2589 verify([source]);
2535 } 2590 }
2536 2591
2537 void test_nonAbstractClassInheritsAbstractMemberOne_ensureCorrectFunctionSubty peIsUsedInImplementation() { 2592 void
2593 test_nonAbstractClassInheritsAbstractMemberOne_ensureCorrectFunctionSubtyp eIsUsedInImplementation() {
2538 // 15028 2594 // 15028
2539 Source source = addSource(r''' 2595 Source source = addSource(r'''
2540 class C { 2596 class C {
2541 foo(int x) => x; 2597 foo(int x) => x;
2542 } 2598 }
2543 abstract class D { 2599 abstract class D {
2544 foo(x, [y]); 2600 foo(x, [y]);
2545 } 2601 }
2546 class E extends C implements D {}'''); 2602 class E extends C implements D {}''');
2547 computeLibrarySourceErrors(source); 2603 computeLibrarySourceErrors(source);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 m(p); 2651 m(p);
2596 } 2652 }
2597 class C extends A { 2653 class C extends A {
2598 }'''); 2654 }''');
2599 computeLibrarySourceErrors(source); 2655 computeLibrarySourceErrors(source);
2600 assertErrors(source, 2656 assertErrors(source,
2601 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2657 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2602 verify([source]); 2658 verify([source]);
2603 } 2659 }
2604 2660
2605 void test_nonAbstractClassInheritsAbstractMemberOne_method_optionalParamCount( ) { 2661 void
2662 test_nonAbstractClassInheritsAbstractMemberOne_method_optionalParamCount() {
2606 // 7640 2663 // 7640
2607 Source source = addSource(r''' 2664 Source source = addSource(r'''
2608 abstract class A { 2665 abstract class A {
2609 int x(int a); 2666 int x(int a);
2610 } 2667 }
2611 abstract class B { 2668 abstract class B {
2612 int x(int a, [int b]); 2669 int x(int a, [int b]);
2613 } 2670 }
2614 class C implements A, B { 2671 class C implements A, B {
2615 }'''); 2672 }''');
(...skipping 29 matching lines...) Expand all
2645 // 15001 2702 // 15001
2646 Source source = addSource(r''' 2703 Source source = addSource(r'''
2647 abstract class A { set s1(v); set s2(v); } 2704 abstract class A { set s1(v); set s2(v); }
2648 abstract class B implements A { set s1(v) {} } 2705 abstract class B implements A { set s1(v) {} }
2649 class C extends Object with B {}'''); 2706 class C extends Object with B {}''');
2650 computeLibrarySourceErrors(source); 2707 computeLibrarySourceErrors(source);
2651 assertErrors(source, 2708 assertErrors(source,
2652 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2709 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2653 } 2710 }
2654 2711
2655 void test_nonAbstractClassInheritsAbstractMemberOne_setter_and_implicitSetter( ) { 2712 void test_nonAbstractClassInheritsAbstractMemberOne_noSuchMethod_interface() {
2713 // 15979
2714 Source source = addSource(r'''
2715 class I {
2716 noSuchMethod(v) => '';
2717 }
2718 abstract class A {
2719 m();
2720 }
2721 class B extends A implements I {
2722 }''');
2723 computeLibrarySourceErrors(source);
2724 assertErrors(source,
2725 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2726 verify([source]);
2727 }
2728
2729 void
2730 test_nonAbstractClassInheritsAbstractMemberOne_setter_and_implicitSetter() {
2656 // test from language/override_inheritance_abstract_test_14.dart 2731 // test from language/override_inheritance_abstract_test_14.dart
2657 Source source = addSource(r''' 2732 Source source = addSource(r'''
2658 abstract class A { 2733 abstract class A {
2659 set field(_); 2734 set field(_);
2660 } 2735 }
2661 abstract class I { 2736 abstract class I {
2662 var field; 2737 var field;
2663 } 2738 }
2664 class B extends A implements I { 2739 class B extends A implements I {
2665 get field => 0; 2740 get field => 0;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 get b => 'b'; 2781 get b => 'b';
2707 } 2782 }
2708 class C extends B { 2783 class C extends B {
2709 }'''); 2784 }''');
2710 computeLibrarySourceErrors(source); 2785 computeLibrarySourceErrors(source);
2711 assertErrors(source, 2786 assertErrors(source,
2712 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2787 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2713 verify([source]); 2788 verify([source]);
2714 } 2789 }
2715 2790
2716 void test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_mis singGetter() { 2791 void
2792 test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_miss ingGetter() {
2717 // 16133 2793 // 16133
2718 Source source = addSource(r''' 2794 Source source = addSource(r'''
2719 class I { 2795 class I {
2720 var v; 2796 var v;
2721 } 2797 }
2722 class C implements I { 2798 class C implements I {
2723 set v(_) {} 2799 set v(_) {}
2724 }'''); 2800 }''');
2725 computeLibrarySourceErrors(source); 2801 computeLibrarySourceErrors(source);
2726 assertErrors(source, 2802 assertErrors(source,
2727 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]); 2803 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE]);
2728 verify([source]); 2804 verify([source]);
2729 } 2805 }
2730 2806
2731 void test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_mis singSetter() { 2807 void
2808 test_nonAbstractClassInheritsAbstractMemberOne_variable_fromInterface_miss ingSetter() {
2732 // 16133 2809 // 16133
2733 Source source = addSource(r''' 2810 Source source = addSource(r'''
2734 class I { 2811 class I {
2735 var v; 2812 var v;
2736 } 2813 }
2737 class C implements I { 2814 class C implements I {
2738 get v => 1; 2815 get v => 1;
2739 }'''); 2816 }''');
2740 computeLibrarySourceErrors(source); 2817 computeLibrarySourceErrors(source);
2741 assertErrors(source, 2818 assertErrors(source,
(...skipping 23 matching lines...) Expand all
2765 n(); 2842 n();
2766 } 2843 }
2767 class C extends A { 2844 class C extends A {
2768 }'''); 2845 }''');
2769 computeLibrarySourceErrors(source); 2846 computeLibrarySourceErrors(source);
2770 assertErrors(source, 2847 assertErrors(source,
2771 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]); 2848 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]);
2772 verify([source]); 2849 verify([source]);
2773 } 2850 }
2774 2851
2775 void test_nonAbstractClassInheritsAbstractMemberTwo_variable_fromInterface_mis singBoth() { 2852 void
2853 test_nonAbstractClassInheritsAbstractMemberTwo_variable_fromInterface_miss ingBoth() {
2776 // 16133 2854 // 16133
2777 Source source = addSource(r''' 2855 Source source = addSource(r'''
2778 class I { 2856 class I {
2779 var v; 2857 var v;
2780 } 2858 }
2781 class C implements I { 2859 class C implements I {
2782 }'''); 2860 }''');
2783 computeLibrarySourceErrors(source); 2861 computeLibrarySourceErrors(source);
2784 assertErrors(source, 2862 assertErrors(source,
2785 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]); 2863 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]);
2786 verify([source]); 2864 verify([source]);
2787 } 2865 }
2788 2866
2867 void
2868 test_nonAbstractClassInheritsAbstractMemberTwo_variable_fromMixin_missingB oth() {
2869 // 26411
2870 resetWithOptions(new AnalysisOptionsImpl()..enableSuperMixins = true);
2871 Source source = addSource(r'''
2872 class A {
2873 int f;
2874 }
2875 class B extends A {}
2876 class C extends Object with B {}
2877 ''');
2878 computeLibrarySourceErrors(source);
2879 assertErrors(source,
2880 [StaticWarningCode.NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO]);
2881 verify([source]);
2882 }
2883
2789 void test_nonTypeInCatchClause_noElement() { 2884 void test_nonTypeInCatchClause_noElement() {
2790 Source source = addSource(r''' 2885 Source source = addSource(r'''
2791 f() { 2886 f() {
2792 try { 2887 try {
2793 } on T catch (e) { 2888 } on T catch (e) {
2794 } 2889 }
2795 }'''); 2890 }''');
2796 computeLibrarySourceErrors(source); 2891 computeLibrarySourceErrors(source);
2797 assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]); 2892 assertErrors(source, [StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE]);
2798 verify([source]); 2893 verify([source]);
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
3151 class A {}''', 3246 class A {}''',
3152 r''' 3247 r'''
3153 library root; 3248 library root;
3154 import 'lib1.dart' deferred as a; 3249 import 'lib1.dart' deferred as a;
3155 a.A f() { return null; }''' 3250 a.A f() { return null; }'''
3156 ], <ErrorCode>[ 3251 ], <ErrorCode>[
3157 StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS 3252 StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS
3158 ]); 3253 ]);
3159 } 3254 }
3160 3255
3161 void test_typeAnnotationDeferredClass_functionTypedFormalParameter_returnType( ) { 3256 void
3257 test_typeAnnotationDeferredClass_functionTypedFormalParameter_returnType() {
3162 resolveWithErrors(<String>[ 3258 resolveWithErrors(<String>[
3163 r''' 3259 r'''
3164 library lib1; 3260 library lib1;
3165 class A {}''', 3261 class A {}''',
3166 r''' 3262 r'''
3167 library root; 3263 library root;
3168 import 'lib1.dart' deferred as a; 3264 import 'lib1.dart' deferred as a;
3169 f(a.A g()) {}''' 3265 f(a.A g()) {}'''
3170 ], <ErrorCode>[ 3266 ], <ErrorCode>[
3171 StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS 3267 StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
3486 import 'lib.dart'; 3582 import 'lib.dart';
3487 class B extends A { 3583 class B extends A {
3488 test() { 3584 test() {
3489 _foo = 42; 3585 _foo = 42;
3490 } 3586 }
3491 }'''); 3587 }''');
3492 computeLibrarySourceErrors(source); 3588 computeLibrarySourceErrors(source);
3493 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); 3589 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]);
3494 } 3590 }
3495 3591
3592 void test_undefinedIdentifierAwait_function() {
3593 Source source = addSource("void a() { await; }");
3594 computeLibrarySourceErrors(source);
3595 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT]);
3596 }
3597
3496 void test_undefinedNamedParameter() { 3598 void test_undefinedNamedParameter() {
3497 Source source = addSource(r''' 3599 Source source = addSource(r'''
3498 f({a, b}) {} 3600 f({a, b}) {}
3499 main() { 3601 main() {
3500 f(c: 1); 3602 f(c: 1);
3501 }'''); 3603 }''');
3502 computeLibrarySourceErrors(source); 3604 computeLibrarySourceErrors(source);
3503 assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]); 3605 assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]);
3504 // no verify(), 'c' is not resolved 3606 // no verify(), 'c' is not resolved
3505 } 3607 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
3579 3681
3580 void test_voidReturnForGetter() { 3682 void test_voidReturnForGetter() {
3581 Source source = addSource(r''' 3683 Source source = addSource(r'''
3582 class S { 3684 class S {
3583 void get value {} 3685 void get value {}
3584 }'''); 3686 }''');
3585 computeLibrarySourceErrors(source); 3687 computeLibrarySourceErrors(source);
3586 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); 3688 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]);
3587 } 3689 }
3588 } 3690 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698