Move tests regarding redundant imports to the unnecessary_import_test file
Work towards https://github.com/dart-lang/sdk/issues/61877
Implementing comments from https://dart-review.googlesource.com/c/sdk/+/458600
Change-Id: I0c13fa154cadc207dca3c7d477e8c34cb53c2cd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
diff --git a/pkg/analyzer/test/src/diagnostics/unnecessary_import_test.dart b/pkg/analyzer/test/src/diagnostics/unnecessary_import_test.dart
index b058e19..a93c811 100644
--- a/pkg/analyzer/test/src/diagnostics/unnecessary_import_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unnecessary_import_test.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/src/error/codes.dart';
+import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/context_collection_resolution.dart';
@@ -184,6 +185,35 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/61877')
+ test_library_export_and_export() async {
+ var a = newFile('$testPackageLibPath/a.dart', r'''
+class C {}
+''');
+
+ var b = newFile('$testPackageLibPath/b.dart', r'''
+export 'a.dart';
+''');
+
+ var c = newFile('$testPackageLibPath/c.dart', r'''
+export 'a.dart';
+''');
+
+ var d = newFile('$testPackageLibPath/d.dart', r'''
+import 'b.dart';
+import 'c.dart';
+
+method() => C();
+''');
+ await assertErrorsInFile2(a, []);
+ await assertErrorsInFile2(b, []);
+ await assertErrorsInFile2(c, []);
+ // Import of 'c.dart' is not marked as unused even though it could be
+ // removed.
+ var result = await resolveFile(d);
+ expect(result.diagnostics, isNotEmpty);
+ }
+
test_library_extension_equalPrefixes_unnecessary() async {
newFile('$testPackageLibPath/lib1.dart', '''
extension E1 on int {
@@ -357,6 +387,30 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/61877')
+ test_library_import_and_export() async {
+ var a = newFile('$testPackageLibPath/a.dart', r'''
+class C {}
+''');
+
+ var b = newFile('$testPackageLibPath/b.dart', r'''
+export 'a.dart';
+''');
+
+ var c = newFile('$testPackageLibPath/c.dart', r'''
+import 'a.dart';
+import 'b.dart';
+
+method() => C();
+''');
+ await assertErrorsInFile2(a, []);
+ await assertErrorsInFile2(b, []);
+ // Import of 'b.dart' is not marked as unused even though it could be
+ // removed.
+ var result = await resolveFile(c);
+ expect(result.diagnostics, isNotEmpty);
+ }
+
test_library_systemShadowing() async {
newFile('$testPackageLibPath/lib1.dart', '''
class File {}
diff --git a/pkg/analyzer/test/src/diagnostics/unused_import_test.dart b/pkg/analyzer/test/src/diagnostics/unused_import_test.dart
index 8036a43..521ad1e 100644
--- a/pkg/analyzer/test/src/diagnostics/unused_import_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/unused_import_test.dart
@@ -65,33 +65,6 @@
''');
}
- test_library_export_and_export() async {
- var a = newFile('$testPackageLibPath/a.dart', r'''
-class C {}
-''');
-
- var b = newFile('$testPackageLibPath/b.dart', r'''
-export 'a.dart';
-''');
-
- var c = newFile('$testPackageLibPath/c.dart', r'''
-export 'a.dart';
-''');
-
- var d = newFile('$testPackageLibPath/d.dart', r'''
-import 'b.dart';
-import 'c.dart';
-
-method() => C();
-''');
- await assertErrorsInFile2(a, []);
- await assertErrorsInFile2(b, []);
- await assertErrorsInFile2(c, []);
- // Import of 'c.dart' is not marked as unused even though it could be
- // removed.
- await assertErrorsInFile2(d, []);
- }
-
test_library_export_infiniteLoop() async {
newFile('$testPackageLibPath/lib1.dart', r'''
export 'lib2.dart';
@@ -360,28 +333,6 @@
);
}
- test_library_import_and_export() async {
- var a = newFile('$testPackageLibPath/a.dart', r'''
-class C {}
-''');
-
- var b = newFile('$testPackageLibPath/b.dart', r'''
-export 'a.dart';
-''');
-
- var c = newFile('$testPackageLibPath/c.dart', r'''
-import 'a.dart';
-import 'b.dart';
-
-method() => C();
-''');
- await assertErrorsInFile2(a, []);
- await assertErrorsInFile2(b, []);
- // Import of 'b.dart' is not marked as unused even though it could be
- // removed.
- await assertErrorsInFile2(c, []);
- }
-
test_library_inComment_libraryDirective() async {
await assertNoErrorsInCode(r'''
/// Use [Future] class.