linter: Move always_declare_return_types tests

Change-Id: I98494413190341307de80243a3ea9ef624a93a4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364629
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/always_declare_return_types_test.dart b/pkg/linter/test/rules/always_declare_return_types_test.dart
index b3f9c04..637f26b 100644
--- a/pkg/linter/test/rules/always_declare_return_types_test.dart
+++ b/pkg/linter/test/rules/always_declare_return_types_test.dart
@@ -61,7 +61,8 @@
     ]);
   }
 
-  /// Augmentation target chain variations tested in `augmentedTopLevelFunction{*}`.
+  /// Augmentation target chain variations tested in
+  /// `augmentedTopLevelFunction{*}`.
   test_augmentedMethod() async {
     var a = newFile('$testPackageLibPath/a.dart', r'''
 import augment 'b.dart';
@@ -132,4 +133,105 @@
     result = await resolveFile(b.path);
     await assertNoDiagnosticsIn(errors);
   }
+
+  test_extensionMethod() async {
+    await assertDiagnostics(r'''
+extension E on int {
+  f() {}
+}
+''', [
+      lint(23, 1),
+    ]);
+  }
+
+  test_instanceSetter() async {
+    await assertNoDiagnostics(r'''
+class C {
+  set f(int p) {}
+}
+''');
+  }
+
+  test_method_expressionBody() async {
+    await assertDiagnostics(r'''
+class C {
+  f() => 42;
+}
+''', [
+      lint(12, 1),
+    ]);
+  }
+
+  test_method_withReturnType() async {
+    await assertNoDiagnostics(r'''
+class C {
+  int f() => 42;
+}
+''');
+  }
+
+  test_operator() async {
+    await assertNoDiagnostics(r'''
+class C {
+  operator []=(int index, int value) //OK: #300
+  {}
+}
+''');
+  }
+
+  test_staticSetter() async {
+    await assertNoDiagnostics(r'''
+class C {
+  static set f(int p) {}
+}
+''');
+  }
+
+  test_topLevelFunction_blockBody_withReturnType() async {
+    await assertNoDiagnostics(r'''
+int f() => 7;
+''');
+  }
+
+  test_topLevelFunction_expressionBody() async {
+    await assertDiagnostics(r'''
+f() => 7;
+''', [
+      lint(0, 1),
+    ]);
+  }
+
+  test_topLevelFunction_expressionBody_withReturnType() async {
+    await assertNoDiagnostics(r'''
+void f() { }
+''');
+  }
+
+  test_topLevelFunction_noReturn() async {
+    await assertDiagnostics(r'''
+f() {}
+''', [
+      lint(0, 1),
+    ]);
+  }
+
+  test_topLevelSetter() async {
+    await assertNoDiagnostics(r'''
+set f(int p) {}
+''');
+  }
+
+  test_typedef_oldStyle() async {
+    await assertDiagnostics(r'''
+typedef t(int x);
+''', [
+      lint(8, 1),
+    ]);
+  }
+
+  test_typedef_oldStyle_withReturnType() async {
+    await assertNoDiagnostics(r'''
+typedef bool t(int x);
+''');
+  }
 }
diff --git a/pkg/linter/test_data/rules/always_declare_return_types.dart b/pkg/linter/test_data/rules/always_declare_return_types.dart
deleted file mode 100644
index 7d3aadb..0000000
--- a/pkg/linter/test_data/rules/always_declare_return_types.dart
+++ /dev/null
@@ -1,44 +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.
-
-main() { } //LINT
-
-bar() => new _Foo(); //LINT
-
-class _Foo {
-  _foo() => 42; //LINT
-}
-
-typedef bad(int x); //LINT
-
-typedef bool predicate(Object o);
-
-void main2() { }
-
-_Foo bar2() => new _Foo();
-
-class _Foo2 {
-  int _foo() => 42;
-}
-
-set speed(int ms) {} //OK
-
-class Car {
-  static set make(String name) {} // OK
-  set speed(int ms) {} //OK
-}
-
-abstract class MyList<E> implements List<E> {
-  @override
-  operator []=(int index, E value) //OK: #300
-  {
-    // ignored.
-  }
-}
-
-class A { }
-
-extension Foo on A {
-  foo() { } // LINT
-}