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

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: 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
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..783300a34f91e86461b576e21ef223e6e6e933df 100644
--- a/pkg/analyzer/test/generated/hint_code_test.dart
+++ b/pkg/analyzer/test/generated/hint_code_test.dart
@@ -2838,6 +2838,60 @@ 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_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'''

Powered by Google App Engine
This is Rietveld 408576698