This repository was archived by the owner on Nov 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +72
-15
lines changed Expand file tree Collapse file tree 3 files changed +72
-15
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ import 'unnecessary_brace_in_string_interps_test.dart'
133
133
as unnecessary_brace_in_string_interps;
134
134
import 'unnecessary_breaks_test.dart' as unnecessary_breaks;
135
135
import 'unnecessary_const_test.dart' as unnecessary_const;
136
+ import 'unnecessary_constructor_name_test.dart' as unnecessary_constructor_name;
136
137
import 'unnecessary_final_test.dart' as unnecessary_final;
137
138
import 'unnecessary_lambdas_test.dart' as unnecessary_lambdas;
138
139
import 'unnecessary_library_directive_test.dart'
@@ -261,6 +262,7 @@ void main() {
261
262
unnecessary_brace_in_string_interps.main ();
262
263
unnecessary_breaks.main ();
263
264
unnecessary_const.main ();
265
+ unnecessary_constructor_name.main ();
264
266
unnecessary_final.main ();
265
267
unnecessary_lambdas.main ();
266
268
unnecessary_library_directive.main ();
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ import 'package:test_reflective_loader/test_reflective_loader.dart' ;
6
+
7
+ import '../rule_test_support.dart' ;
8
+
9
+ main () {
10
+ defineReflectiveSuite (() {
11
+ defineReflectiveTests (UnnecessaryConstructorNameTest );
12
+ });
13
+ }
14
+
15
+ @reflectiveTest
16
+ class UnnecessaryConstructorNameTest extends LintRuleTest {
17
+ @override
18
+ String get lintRule => 'unnecessary_constructor_name' ;
19
+
20
+ test_constructorDeclaration_named () async {
21
+ await assertNoDiagnostics (r'''
22
+ class A {
23
+ A.ok();
24
+ }
25
+ ''' );
26
+ }
27
+
28
+ test_constructorDeclaration_new () async {
29
+ await assertDiagnostics (r'''
30
+ class A {
31
+ A.new();
32
+ }
33
+ ''' , [
34
+ lint (14 , 3 ),
35
+ ]);
36
+ }
37
+
38
+ test_constructorTearoff_new () async {
39
+ await assertNoDiagnostics (r'''
40
+ class A {
41
+ }
42
+ var makeA = A.new;
43
+ ''' );
44
+ }
45
+
46
+ test_instanceCreation_named () async {
47
+ await assertNoDiagnostics (r'''
48
+ class A {
49
+ A.ok();
50
+ }
51
+ var aaa = A.ok();
52
+ ''' );
53
+ }
54
+
55
+ test_instanceCreation_new () async {
56
+ await assertDiagnostics (r'''
57
+ class A {}
58
+ var a = A.new();
59
+ ''' , [
60
+ lint (21 , 3 ),
61
+ ]);
62
+ }
63
+
64
+ test_instanceCreation_unnamed () async {
65
+ await assertNoDiagnostics (r'''
66
+ class A {}
67
+ var aa = A();
68
+ ''' );
69
+ }
70
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments