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

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

Issue 1863103002: Add an UNUSED_SHOWN_NAMES hint to the analyzer (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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) 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 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 r''' 2831 r'''
2832 library lib1; 2832 library lib1;
2833 class A {} 2833 class A {}
2834 class B {}'''); 2834 class B {}''');
2835 computeLibrarySourceErrors(source); 2835 computeLibrarySourceErrors(source);
2836 assertErrors(source, [HintCode.UNUSED_IMPORT]); 2836 assertErrors(source, [HintCode.UNUSED_IMPORT]);
2837 assertNoErrors(source2); 2837 assertNoErrors(source2);
2838 verify([source, source2]); 2838 verify([source, source2]);
2839 } 2839 }
2840 2840
2841 void test_unusedShownName() {
2842 Source source = addSource(r'''
2843 library L;
2844 import 'lib1.dart' show A, B;
2845 A a;''');
2846 Source source2 = addNamedSource(
2847 "/lib1.dart", r'''
2848 library lib1;
2849 class A {}
2850 class B {}''');
2851 computeLibrarySourceErrors(source);
2852 assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
2853 assertNoErrors(source2);
2854 verify([source, source2]);
2855 }
2856
2857 void test_unusedShownName_as() {
2858 Source source = addSource(r'''
2859 library L;
2860 import 'lib1.dart' as p show A, B;
2861 p.A a;''');
2862 Source source2 = addNamedSource(
2863 "/lib1.dart", r'''
2864 library lib1;
2865 class A {}
2866 class B {}''');
2867 computeLibrarySourceErrors(source);
2868 assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
2869 assertNoErrors(source2);
2870 verify([source, source2]);
2871 }
2872
2873 void test_unusedShownName_duplicates() {
2874 Source source = addSource(r'''
2875 library L;
2876 import 'lib1.dart' show A, B;
2877 import 'lib1.dart' show C, D;
2878 A a;
2879 C c;''');
2880 Source source2 = addNamedSource(
2881 "/lib1.dart", r'''
2882 library lib1;
2883 class A {}
2884 class B {}
2885 class C {}
2886 class D {}''');
2887 computeLibrarySourceErrors(source);
2888 assertErrors(source, [
2889 HintCode.UNUSED_SHOWN_NAME,
2890 HintCode.UNUSED_SHOWN_NAME]);
2891 assertNoErrors(source2);
2892 verify([source, source2]);
2893 }
2894
2841 void test_unusedLocalVariable_inCatch_exception() { 2895 void test_unusedLocalVariable_inCatch_exception() {
2842 enableUnusedLocalVariable = true; 2896 enableUnusedLocalVariable = true;
2843 Source source = addSource(r''' 2897 Source source = addSource(r'''
2844 main() { 2898 main() {
2845 try { 2899 try {
2846 } on String catch (exception) { 2900 } on String catch (exception) {
2847 } 2901 }
2848 }'''); 2902 }''');
2849 computeLibrarySourceErrors(source); 2903 computeLibrarySourceErrors(source);
2850 assertErrors(source, [HintCode.UNUSED_CATCH_CLAUSE]); 2904 assertErrors(source, [HintCode.UNUSED_CATCH_CLAUSE]);
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
3099 n() { 3153 n() {
3100 var a = m(), b = m(); 3154 var a = m(), b = m();
3101 } 3155 }
3102 }'''); 3156 }''');
3103 computeLibrarySourceErrors(source); 3157 computeLibrarySourceErrors(source);
3104 assertErrors( 3158 assertErrors(
3105 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 3159 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
3106 verify([source]); 3160 verify([source]);
3107 } 3161 }
3108 } 3162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698