| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.hint_code_test; | 5 library analyzer.test.generated.hint_code_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
| 8 import 'package:analyzer/src/generated/error.dart'; | 8 import 'package:analyzer/src/generated/error.dart'; |
| 9 import 'package:analyzer/src/generated/source_io.dart'; | 9 import 'package:analyzer/src/generated/source_io.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 } | 617 } |
| 618 f(A a) { | 618 f(A a) { |
| 619 A b; | 619 A b; |
| 620 a += b; | 620 a += b; |
| 621 }'''); | 621 }'''); |
| 622 computeLibrarySourceErrors(source); | 622 computeLibrarySourceErrors(source); |
| 623 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); | 623 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 624 verify([source]); | 624 verify([source]); |
| 625 } | 625 } |
| 626 | 626 |
| 627 void test_deprecatedAnnotationUse_Deprecated() { | 627 void test_deprecatedAnnotationUse_deprecated() { |
| 628 Source source = addSource(r''' | 628 Source source = addSource(r''' |
| 629 class A { | 629 class A { |
| 630 @Deprecated('0.9') | 630 @deprecated |
| 631 m() {} | 631 m() {} |
| 632 n() {m();} | 632 n() {m();} |
| 633 }'''); | 633 }'''); |
| 634 computeLibrarySourceErrors(source); | 634 computeLibrarySourceErrors(source); |
| 635 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); | 635 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 636 verify([source]); | 636 verify([source]); |
| 637 } | 637 } |
| 638 | 638 |
| 639 void test_deprecatedAnnotationUse_deprecated() { | 639 void test_deprecatedAnnotationUse_Deprecated() { |
| 640 Source source = addSource(r''' | 640 Source source = addSource(r''' |
| 641 class A { | 641 class A { |
| 642 @deprecated | 642 @Deprecated('0.9') |
| 643 m() {} | 643 m() {} |
| 644 n() {m();} | 644 n() {m();} |
| 645 }'''); | 645 }'''); |
| 646 computeLibrarySourceErrors(source); | 646 computeLibrarySourceErrors(source); |
| 647 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); | 647 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 648 verify([source]); | 648 verify([source]); |
| 649 } | 649 } |
| 650 | 650 |
| 651 void test_deprecatedAnnotationUse_export() { | 651 void test_deprecatedAnnotationUse_export() { |
| 652 Source source = addSource("export 'deprecated_library.dart';"); | 652 Source source = addSource("export 'deprecated_library.dart';"); |
| 653 addNamedSource( | 653 addNamedSource( |
| 654 "/deprecated_library.dart", | 654 "/deprecated_library.dart", |
| 655 r''' | 655 r''' |
| 656 @deprecated | 656 @deprecated |
| 657 library deprecated_library; | 657 library deprecated_library; |
| 658 class A {}'''); | 658 class A {}'''); |
| 659 computeLibrarySourceErrors(source); | 659 computeLibrarySourceErrors(source); |
| 660 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); | 660 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 661 verify([source]); | 661 verify([source]); |
| 662 } | 662 } |
| 663 | 663 |
| 664 void test_deprecatedAnnotationUse_field() { |
| 665 Source source = addSource(r''' |
| 666 class A { |
| 667 @deprecated |
| 668 int x = 1; |
| 669 } |
| 670 f(A a) { |
| 671 return a.x; |
| 672 }'''); |
| 673 computeLibrarySourceErrors(source); |
| 674 assertErrors(source, [HintCode.DEPRECATED_MEMBER_USE]); |
| 675 verify([source]); |
| 676 } |
| 677 |
| 664 void test_deprecatedAnnotationUse_getter() { | 678 void test_deprecatedAnnotationUse_getter() { |
| 665 Source source = addSource(r''' | 679 Source source = addSource(r''' |
| 666 class A { | 680 class A { |
| 667 @deprecated | 681 @deprecated |
| 668 get m => 1; | 682 get m => 1; |
| 669 } | 683 } |
| 670 f(A a) { | 684 f(A a) { |
| 671 return a.m; | 685 return a.m; |
| 672 }'''); | 686 }'''); |
| 673 computeLibrarySourceErrors(source); | 687 computeLibrarySourceErrors(source); |
| (...skipping 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2974 n() { | 2988 n() { |
| 2975 var a = m(), b = m(); | 2989 var a = m(), b = m(); |
| 2976 } | 2990 } |
| 2977 }'''); | 2991 }'''); |
| 2978 computeLibrarySourceErrors(source); | 2992 computeLibrarySourceErrors(source); |
| 2979 assertErrors( | 2993 assertErrors( |
| 2980 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); | 2994 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); |
| 2981 verify([source]); | 2995 verify([source]); |
| 2982 } | 2996 } |
| 2983 } | 2997 } |
| OLD | NEW |