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

Unified 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: Fix top-level variables 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/hint_code_test.dart
diff --git a/pkg/analyzer/test/generated/hint_code_test.dart b/pkg/analyzer/test/generated/hint_code_test.dart
index fa3da216fadc4f776d7becfc8124e281c4ad2bae..242da2f162d814b55c325632c65dae4da1acbe20 100644
--- a/pkg/analyzer/test/generated/hint_code_test.dart
+++ b/pkg/analyzer/test/generated/hint_code_test.dart
@@ -2838,6 +2838,82 @@ class B {}''');
verify([source, source2]);
}
+ void test_unusedShownName() {
+ Source source = addSource(r'''
+library L;
+import 'lib1.dart' show A, B;
+A a;''');
+ Source source2 = addNamedSource(
+ "/lib1.dart", r'''
+library lib1;
+class A {}
+class B {}''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
+ assertNoErrors(source2);
+ verify([source, source2]);
+ }
+
+ void test_unusedShownName_topLevelVariable() {
+ Source source = addSource(r'''
+library L;
+import 'lib1.dart' show var1, var2;
+import 'lib1.dart' show var3, var4;
+int a = var1;
+int b = var2;
+int c = var3;''');
+ Source source2 = addNamedSource(
+ "/lib1.dart",
+ r'''
+library lib1;
+const int var1 = 1;
+const int var2 = 2;
+const int var3 = 3;
+const int var4 = 4;''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
+ assertNoErrors(source2);
+ verify([source, source2]);
+ }
+
+ void test_unusedShownName_as() {
+ Source source = addSource(r'''
+library L;
+import 'lib1.dart' as p show A, B;
+p.A a;''');
+ Source source2 = addNamedSource(
+ "/lib1.dart", r'''
+library lib1;
+class A {}
+class B {}''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [HintCode.UNUSED_SHOWN_NAME]);
+ assertNoErrors(source2);
+ verify([source, source2]);
+ }
+
+ void test_unusedShownName_duplicates() {
+ Source source = addSource(r'''
+library L;
+import 'lib1.dart' show A, B;
+import 'lib1.dart' show C, D;
+A a;
+C c;''');
+ Source source2 = addNamedSource(
+ "/lib1.dart", r'''
+library lib1;
+class A {}
+class B {}
+class C {}
+class D {}''');
+ computeLibrarySourceErrors(source);
+ assertErrors(source, [
+ HintCode.UNUSED_SHOWN_NAME,
+ HintCode.UNUSED_SHOWN_NAME]);
+ assertNoErrors(source2);
+ verify([source, source2]);
+ }
+
void test_unusedLocalVariable_inCatch_exception() {
enableUnusedLocalVariable = true;
Source source = addSource(r'''
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698