lint rules: Migrate tests for type_init_formals
Change-Id: I409a639518dd165e4f422eef664fda7601b2e75c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398820
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
diff --git a/pkg/linter/test/rules/type_init_formals_test.dart b/pkg/linter/test/rules/type_init_formals_test.dart
index 97394ad..93e8d79 100644
--- a/pkg/linter/test/rules/type_init_formals_test.dart
+++ b/pkg/linter/test/rules/type_init_formals_test.dart
@@ -88,4 +88,43 @@
lint(66, 7),
]);
}
+
+ test_typed_fieldIsDynamic() async {
+ await assertNoDiagnostics(r'''
+class C {
+ var x;
+ C(int this.x);
+}
+''');
+ }
+
+ test_typed_sameAsField() async {
+ await assertDiagnostics(r'''
+class C {
+ int x;
+ C(int this.x);
+}
+''', [
+ lint(23, 3),
+ ]);
+ }
+
+ test_typed_subtypeOfField() async {
+ await assertNoDiagnostics(r'''
+class C {
+ num x;
+ C.i(int this.x);
+ C.d(double this.x);
+}
+''');
+ }
+
+ test_untyped() async {
+ await assertNoDiagnostics(r'''
+class C {
+ int x;
+ C(this.x);
+}
+''');
+ }
}
diff --git a/pkg/linter/test_data/rules/type_init_formals.dart b/pkg/linter/test_data/rules/type_init_formals.dart
deleted file mode 100644
index 12681a8..0000000
--- a/pkg/linter/test_data/rules/type_init_formals.dart
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2015, 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.
-
-class Good {
- String name;
- Good(this.name); // OK
-}
-
-class Bad {
- String name;
- Bad(String this.name); //LINT [7:6]
-}
-
-class Good2 {
- num a;
- Good2.i(int this.a); // OK
- Good2.d(double this.a); // OK
-}
-
-class Good3 {
- var a;
- Good3(int this.a); // OK
-}
-