[enhanced-parts] test “Organize Imports”
Fixes: https://github.com/dart-lang/sdk/issues/56683 Change-Id: I6b6aae385d4313e551f7c110e1e2544cc418a5a8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384308 Commit-Queue: Phil Quitslund <pquitslund@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Auto-Submit: Phil Quitslund <pquitslund@google.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import 'package:analyzer/src/services/available_declarations.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart'
|
||||
hide AnalysisError;
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:analyzer_utilities/test/experiments/experiments.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -89,7 +90,7 @@ abstract class BulkFixProcessorTest extends AbstractSingleUnitTest {
|
||||
late BulkFixProcessor processor;
|
||||
|
||||
@override
|
||||
List<String> get experiments => const [];
|
||||
List<String> get experiments => experimentsForTests;
|
||||
|
||||
/// The name of the lint code being tested.
|
||||
String? get lintCode => null;
|
||||
|
||||
@@ -12,31 +12,79 @@ import 'fix_processor.dart';
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(OrganizeImportsBulkTest);
|
||||
defineReflectiveTests(OrganizeImportsTest);
|
||||
defineReflectiveTests(OrganizeImportsDirectivesOrderingTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class OrganizeImportsBulkTest extends BulkFixProcessorTest {
|
||||
Future<void> test_partFile() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
part 'test.dart';
|
||||
''');
|
||||
|
||||
await resolveTestCode('''
|
||||
part of 'a.dart';
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:async';
|
||||
|
||||
Future? a;
|
||||
''');
|
||||
|
||||
await assertOrganize('''
|
||||
part of 'a.dart';
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
Future? a;
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_single_file() async {
|
||||
await parseTestCode('''
|
||||
import 'dart:io';
|
||||
import 'dart:async';
|
||||
|
||||
Future a;
|
||||
Future? a;
|
||||
''');
|
||||
|
||||
await assertOrganize('''
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
Future a;
|
||||
Future? a;
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_withParts() async {
|
||||
newFile('$testPackageLibPath/a.dart', r'''
|
||||
part of 'test.dart';
|
||||
''');
|
||||
|
||||
await parseTestCode('''
|
||||
import 'dart:io';
|
||||
import 'dart:async';
|
||||
|
||||
part 'a.dart';
|
||||
|
||||
Future? a;
|
||||
''');
|
||||
|
||||
await assertOrganize('''
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
part 'a.dart';
|
||||
|
||||
Future? a;
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class OrganizeImportsTest extends FixProcessorLintTest {
|
||||
class OrganizeImportsDirectivesOrderingTest extends FixProcessorLintTest {
|
||||
@override
|
||||
FixKind get kind => DartFixKind.ORGANIZE_IMPORTS;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user