blob: fcf9c8b193342a6771e7f571e1a55311a1bf4cc4 [file] [log] [blame]
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/src/services/correction/fix.dart';
import 'package:analysis_server/src/services/linter/lint_names.dart';
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../abstract_context.dart';
import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
defineReflectiveTests(AddRequiredTest);
defineReflectiveTests(AddRequiredWithNullSafetyTest);
});
}
@reflectiveTest
class AddRequiredTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.ADD_REQUIRED;
@override
String get lintCode => LintNames.always_require_non_null_named_parameters;
Future<void> test_withAssert() async {
await resolveTestUnit('''
void function({String param}) {
assert(param != null);
}
''');
await assertHasFix('''
void function({@required String param}) {
assert(param != null);
}
''');
}
}
@reflectiveTest
class AddRequiredWithNullSafetyTest extends FixProcessorTest
with WithNullSafetyMixin {
@override
FixKind get kind => DartFixKind.ADD_REQUIRED2;
Future<void> test_withAssert() async {
await resolveTestUnit('''
void function({String param}) {}
''');
await assertHasFix('''
void function({required String param}) {}
''');
}
}