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

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

Issue 2626653002: Remove computeLibrarySourceErrors(). (Closed)
Patch Set: Created 3 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
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 analyzer.test.generated.resolver_test; 5 library analyzer.test.generated.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 class A { 165 class A {
166 void m(int i) { 166 void m(int i) {
167 switch (i) { 167 switch (i) {
168 l: case 0: 168 l: case 0:
169 break; 169 break;
170 case 1: 170 case 1:
171 break l; 171 break l;
172 } 172 }
173 } 173 }
174 }'''); 174 }''');
175 computeLibrarySourceErrors(source);
176 assertErrors(source, [ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]); 175 assertErrors(source, [ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER]);
177 verify([source]); 176 verify([source]);
178 } 177 }
179 178
180 void test_continueLabelOnSwitch() { 179 void test_continueLabelOnSwitch() {
181 Source source = addSource(r''' 180 Source source = addSource(r'''
182 class A { 181 class A {
183 void m(int i) { 182 void m(int i) {
184 l: switch (i) { 183 l: switch (i) {
185 case 0: 184 case 0:
186 continue l; 185 continue l;
187 } 186 }
188 } 187 }
189 }'''); 188 }''');
190 computeLibrarySourceErrors(source);
191 assertErrors(source, [ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]); 189 assertErrors(source, [ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH]);
192 verify([source]); 190 verify([source]);
193 } 191 }
194 192
195 void test_enclosingElement_invalidLocalFunction() { 193 void test_enclosingElement_invalidLocalFunction() {
196 Source source = addSource(r''' 194 Source source = addSource(r'''
197 class C { 195 class C {
198 C() { 196 C() {
199 int get x => 0; 197 int get x => 0;
200 } 198 }
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 @reflectiveTest 614 @reflectiveTest
617 class StrictModeTest extends ResolverTestCase { 615 class StrictModeTest extends ResolverTestCase {
618 void fail_for() { 616 void fail_for() {
619 Source source = addSource(r''' 617 Source source = addSource(r'''
620 int f(List<int> list) { 618 int f(List<int> list) {
621 num sum = 0; 619 num sum = 0;
622 for (num i = 0; i < list.length; i++) { 620 for (num i = 0; i < list.length; i++) {
623 sum += list[i]; 621 sum += list[i];
624 } 622 }
625 }'''); 623 }''');
626 computeLibrarySourceErrors(source);
627 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); 624 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
628 } 625 }
629 626
630 @override 627 @override
631 void setUp() { 628 void setUp() {
632 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); 629 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
633 options.hint = false; 630 options.hint = false;
634 resetWithOptions(options); 631 resetWithOptions(options);
635 } 632 }
636 633
637 void test_assert_is() { 634 void test_assert_is() {
638 Source source = addSource(r''' 635 Source source = addSource(r'''
639 int f(num n) { 636 int f(num n) {
640 assert (n is int); 637 assert (n is int);
641 return n & 0x0F; 638 return n & 0x0F;
642 }'''); 639 }''');
643 computeLibrarySourceErrors(source);
644 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); 640 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
645 } 641 }
646 642
647 void test_conditional_and_is() { 643 void test_conditional_and_is() {
648 Source source = addSource(r''' 644 Source source = addSource(r'''
649 int f(num n) { 645 int f(num n) {
650 return (n is int && n > 0) ? n & 0x0F : 0; 646 return (n is int && n > 0) ? n & 0x0F : 0;
651 }'''); 647 }''');
652 computeLibrarySourceErrors(source);
653 assertNoErrors(source); 648 assertNoErrors(source);
654 } 649 }
655 650
656 void test_conditional_is() { 651 void test_conditional_is() {
657 Source source = addSource(r''' 652 Source source = addSource(r'''
658 int f(num n) { 653 int f(num n) {
659 return (n is int) ? n & 0x0F : 0; 654 return (n is int) ? n & 0x0F : 0;
660 }'''); 655 }''');
661 computeLibrarySourceErrors(source);
662 assertNoErrors(source); 656 assertNoErrors(source);
663 } 657 }
664 658
665 void test_conditional_isNot() { 659 void test_conditional_isNot() {
666 Source source = addSource(r''' 660 Source source = addSource(r'''
667 int f(num n) { 661 int f(num n) {
668 return (n is! int) ? 0 : n & 0x0F; 662 return (n is! int) ? 0 : n & 0x0F;
669 }'''); 663 }''');
670 computeLibrarySourceErrors(source);
671 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); 664 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
672 } 665 }
673 666
674 void test_conditional_or_is() { 667 void test_conditional_or_is() {
675 Source source = addSource(r''' 668 Source source = addSource(r'''
676 int f(num n) { 669 int f(num n) {
677 return (n is! int || n < 0) ? 0 : n & 0x0F; 670 return (n is! int || n < 0) ? 0 : n & 0x0F;
678 }'''); 671 }''');
679 computeLibrarySourceErrors(source);
680 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); 672 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
681 } 673 }
682 674
683 void test_forEach() { 675 void test_forEach() {
684 Source source = addSource(r''' 676 Source source = addSource(r'''
685 int f(List<int> list) { 677 int f(List<int> list) {
686 num sum = 0; 678 num sum = 0;
687 for (num n in list) { 679 for (num n in list) {
688 sum += n & 0x0F; 680 sum += n & 0x0F;
689 } 681 }
690 }'''); 682 }''');
691 computeLibrarySourceErrors(source);
692 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); 683 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
693 } 684 }
694 685
695 void test_if_and_is() { 686 void test_if_and_is() {
696 Source source = addSource(r''' 687 Source source = addSource(r'''
697 int f(num n) { 688 int f(num n) {
698 if (n is int && n > 0) { 689 if (n is int && n > 0) {
699 return n & 0x0F; 690 return n & 0x0F;
700 } 691 }
701 return 0; 692 return 0;
702 }'''); 693 }''');
703 computeLibrarySourceErrors(source);
704 assertNoErrors(source); 694 assertNoErrors(source);
705 } 695 }
706 696
707 void test_if_is() { 697 void test_if_is() {
708 Source source = addSource(r''' 698 Source source = addSource(r'''
709 int f(num n) { 699 int f(num n) {
710 if (n is int) { 700 if (n is int) {
711 return n & 0x0F; 701 return n & 0x0F;
712 } 702 }
713 return 0; 703 return 0;
714 }'''); 704 }''');
715 computeLibrarySourceErrors(source);
716 assertNoErrors(source); 705 assertNoErrors(source);
717 } 706 }
718 707
719 void test_if_isNot() { 708 void test_if_isNot() {
720 Source source = addSource(r''' 709 Source source = addSource(r'''
721 int f(num n) { 710 int f(num n) {
722 if (n is! int) { 711 if (n is! int) {
723 return 0; 712 return 0;
724 } else { 713 } else {
725 return n & 0x0F; 714 return n & 0x0F;
726 } 715 }
727 }'''); 716 }''');
728 computeLibrarySourceErrors(source);
729 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); 717 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
730 } 718 }
731 719
732 void test_if_isNot_abrupt() { 720 void test_if_isNot_abrupt() {
733 Source source = addSource(r''' 721 Source source = addSource(r'''
734 int f(num n) { 722 int f(num n) {
735 if (n is! int) { 723 if (n is! int) {
736 return 0; 724 return 0;
737 } 725 }
738 return n & 0x0F; 726 return n & 0x0F;
739 }'''); 727 }''');
740 computeLibrarySourceErrors(source);
741 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); 728 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
742 } 729 }
743 730
744 void test_if_or_is() { 731 void test_if_or_is() {
745 Source source = addSource(r''' 732 Source source = addSource(r'''
746 int f(num n) { 733 int f(num n) {
747 if (n is! int || n < 0) { 734 if (n is! int || n < 0) {
748 return 0; 735 return 0;
749 } else { 736 } else {
750 return n & 0x0F; 737 return n & 0x0F;
751 } 738 }
752 }'''); 739 }''');
753 computeLibrarySourceErrors(source);
754 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); 740 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
755 } 741 }
756 742
757 void test_localVar() { 743 void test_localVar() {
758 Source source = addSource(r''' 744 Source source = addSource(r'''
759 int f() { 745 int f() {
760 num n = 1234; 746 num n = 1234;
761 return n & 0x0F; 747 return n & 0x0F;
762 }'''); 748 }''');
763 computeLibrarySourceErrors(source);
764 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]); 749 assertErrors(source, [StaticTypeWarningCode.UNDEFINED_OPERATOR]);
765 } 750 }
766 } 751 }
767 752
768 @reflectiveTest 753 @reflectiveTest
769 class SubtypeManagerTest { 754 class SubtypeManagerTest {
770 /** 755 /**
771 * The inheritance manager being tested. 756 * The inheritance manager being tested.
772 */ 757 */
773 SubtypeManager _subtypeManager; 758 SubtypeManager _subtypeManager;
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 } 2226 }
2242 } 2227 }
2243 2228
2244 void g() { 2229 void g() {
2245 Base x = null; 2230 Base x = null;
2246 if (x is Derived) { 2231 if (x is Derived) {
2247 print(x.y); // GOOD 2232 print(x.y); // GOOD
2248 } 2233 }
2249 x = null; 2234 x = null;
2250 }'''); 2235 }''');
2251 computeLibrarySourceErrors(source);
2252 assertNoErrors(source); 2236 assertNoErrors(source);
2253 } 2237 }
2254 2238
2255 void test_objectAccessInference_disabled_for_library_prefix() { 2239 void test_objectAccessInference_disabled_for_library_prefix() {
2256 String name = 'hashCode'; 2240 String name = 'hashCode';
2257 addNamedSource( 2241 addNamedSource(
2258 '/helper.dart', 2242 '/helper.dart',
2259 ''' 2243 '''
2260 library helper; 2244 library helper;
2261 dynamic get $name => 42; 2245 dynamic get $name => 42;
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
3666 */ 3650 */
3667 class _StaleElement extends ElementImpl { 3651 class _StaleElement extends ElementImpl {
3668 _StaleElement() : super("_StaleElement", -1); 3652 _StaleElement() : super("_StaleElement", -1);
3669 3653
3670 @override 3654 @override
3671 get kind => throw "_StaleElement's kind shouldn't be accessed"; 3655 get kind => throw "_StaleElement's kind shouldn't be accessed";
3672 3656
3673 @override 3657 @override
3674 /*=T*/ accept/*<T>*/(_) => throw "_StaleElement shouldn't be visited"; 3658 /*=T*/ accept/*<T>*/(_) => throw "_StaleElement shouldn't be visited";
3675 } 3659 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/non_hint_code_test.dart ('k') | pkg/analyzer/test/generated/resolver_test_case.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698