Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Move unnecessary_constructor_name tests (#4501)
Browse files Browse the repository at this point in the history
  • Loading branch information
srawlins authored Jun 27, 2023
1 parent 9012511 commit cf4fbcd
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 15 deletions.
2 changes: 2 additions & 0 deletions test/rules/all.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ import 'unnecessary_brace_in_string_interps_test.dart'
as unnecessary_brace_in_string_interps;
import 'unnecessary_breaks_test.dart' as unnecessary_breaks;
import 'unnecessary_const_test.dart' as unnecessary_const;
import 'unnecessary_constructor_name_test.dart' as unnecessary_constructor_name;
import 'unnecessary_final_test.dart' as unnecessary_final;
import 'unnecessary_lambdas_test.dart' as unnecessary_lambdas;
import 'unnecessary_library_directive_test.dart'
Expand Down Expand Up @@ -261,6 +262,7 @@ void main() {
unnecessary_brace_in_string_interps.main();
unnecessary_breaks.main();
unnecessary_const.main();
unnecessary_constructor_name.main();
unnecessary_final.main();
unnecessary_lambdas.main();
unnecessary_library_directive.main();
Expand Down
70 changes: 70 additions & 0 deletions test/rules/unnecessary_constructor_name_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright (c) 2023, 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:test_reflective_loader/test_reflective_loader.dart';

import '../rule_test_support.dart';

main() {
defineReflectiveSuite(() {
defineReflectiveTests(UnnecessaryConstructorNameTest);
});
}

@reflectiveTest
class UnnecessaryConstructorNameTest extends LintRuleTest {
@override
String get lintRule => 'unnecessary_constructor_name';

test_constructorDeclaration_named() async {
await assertNoDiagnostics(r'''
class A {
A.ok();
}
''');
}

test_constructorDeclaration_new() async {
await assertDiagnostics(r'''
class A {
A.new();
}
''', [
lint(14, 3),
]);
}

test_constructorTearoff_new() async {
await assertNoDiagnostics(r'''
class A {
}
var makeA = A.new;
''');
}

test_instanceCreation_named() async {
await assertNoDiagnostics(r'''
class A {
A.ok();
}
var aaa = A.ok();
''');
}

test_instanceCreation_new() async {
await assertDiagnostics(r'''
class A {}
var a = A.new();
''', [
lint(21, 3),
]);
}

test_instanceCreation_unnamed() async {
await assertNoDiagnostics(r'''
class A {}
var aa = A();
''');
}
}
15 changes: 0 additions & 15 deletions test_data/rules/unnecessary_constructor_name.dart

This file was deleted.

0 comments on commit cf4fbcd

Please sign in to comment.