Analyzer: Refactor and rename 8 test classes in 4 files to use TestCase model
The diffs may look large, but only due to sorting. No tests were added,
removed, or altered.
Change-Id: I55246391205a8a234c05b9e1aa3ec681a178f973
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209361
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/equality_expressions_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/equality_expressions_test.dart
index d56dc4a..bc5d454 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/equality_expressions_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/equality_expressions_test.dart
@@ -9,14 +9,16 @@
main() {
defineReflectiveSuite(() {
defineReflectiveTests(EqualTest);
- defineReflectiveTests(EqualWithNullSafetyTest);
+ defineReflectiveTests(EqualWithoutNullSafetyTest);
defineReflectiveTests(NotEqualTest);
- defineReflectiveTests(NotEqualWithNullSafetyTest);
+ defineReflectiveTests(NotEqualWithoutNullSafetyTest);
});
}
@reflectiveTest
-class EqualTest extends PubPackageResolutionTest with WithoutNullSafetyMixin {
+class EqualTest extends PubPackageResolutionTest with EqualTestCases {}
+
+mixin EqualTestCases on PubPackageResolutionTest {
test_simple() async {
await resolveTestCode('''
void f(Object a, Object b) {
@@ -29,11 +31,13 @@
}
@reflectiveTest
-class EqualWithNullSafetyTest extends EqualTest with WithNullSafetyMixin {}
+class EqualWithoutNullSafetyTest extends PubPackageResolutionTest
+ with EqualTestCases, WithoutNullSafetyMixin {}
@reflectiveTest
-class NotEqualTest extends PubPackageResolutionTest
- with WithoutNullSafetyMixin {
+class NotEqualTest extends PubPackageResolutionTest with NotEqualTestCases {}
+
+mixin NotEqualTestCases on PubPackageResolutionTest {
test_simple() async {
await resolveTestCode('''
void f(Object a, Object b) {
@@ -46,5 +50,5 @@
}
@reflectiveTest
-class NotEqualWithNullSafetyTest extends NotEqualTest with WithNullSafetyMixin {
-}
+class NotEqualWithoutNullSafetyTest extends PubPackageResolutionTest
+ with NotEqualTestCases, WithoutNullSafetyMixin {}
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/logical_boolean_expressions_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/logical_boolean_expressions_test.dart
index 209ac2b..bb81efe 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/logical_boolean_expressions_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/logical_boolean_expressions_test.dart
@@ -9,29 +9,14 @@
main() {
defineReflectiveSuite(() {
defineReflectiveTests(LogicalAndTest);
- defineReflectiveTests(LogicalAndWithNullSafetyTest);
+ defineReflectiveTests(LogicalAndWithoutNullSafetyTest);
defineReflectiveTests(LogicalOrTest);
- defineReflectiveTests(LogicalOrWithNullSafetyTest);
+ defineReflectiveTests(LogicalOrWithoutNullSafetyTest);
});
}
@reflectiveTest
-class LogicalAndTest extends PubPackageResolutionTest
- with WithoutNullSafetyMixin {
- test_upward() async {
- await resolveTestCode('''
-void f(bool a, bool b) {
- var c = a && b;
- print(c);
-}
-''');
- assertType(findNode.simple('c)'), 'bool');
- }
-}
-
-@reflectiveTest
-class LogicalAndWithNullSafetyTest extends LogicalAndTest
- with WithNullSafetyMixin {
+class LogicalAndTest extends PubPackageResolutionTest with LogicalAndTestCases {
@failingTest
test_downward() async {
await resolveTestCode('''
@@ -47,13 +32,11 @@
}
}
-@reflectiveTest
-class LogicalOrTest extends PubPackageResolutionTest
- with WithoutNullSafetyMixin {
+mixin LogicalAndTestCases on PubPackageResolutionTest {
test_upward() async {
await resolveTestCode('''
void f(bool a, bool b) {
- var c = a || b;
+ var c = a && b;
print(c);
}
''');
@@ -62,8 +45,11 @@
}
@reflectiveTest
-class LogicalOrWithNullSafetyTest extends LogicalOrTest
- with WithNullSafetyMixin {
+class LogicalAndWithoutNullSafetyTest extends PubPackageResolutionTest
+ with LogicalAndTestCases, WithoutNullSafetyMixin {}
+
+@reflectiveTest
+class LogicalOrTest extends PubPackageResolutionTest with LogicalOrTestCases {
@failingTest
test_downward() async {
await resolveTestCode('''
@@ -78,3 +64,19 @@
assertInvokeType(findNode.methodInvocation('b('), 'bool Function()');
}
}
+
+mixin LogicalOrTestCases on PubPackageResolutionTest {
+ test_upward() async {
+ await resolveTestCode('''
+void f(bool a, bool b) {
+ var c = a || b;
+ print(c);
+}
+''');
+ assertType(findNode.simple('c)'), 'bool');
+ }
+}
+
+@reflectiveTest
+class LogicalOrWithoutNullSafetyTest extends PubPackageResolutionTest
+ with LogicalOrTestCases, WithoutNullSafetyMixin {}
diff --git a/pkg/analyzer/test/src/dart/resolution/type_inference/type_test_expressions_test.dart b/pkg/analyzer/test/src/dart/resolution/type_inference/type_test_expressions_test.dart
index 7e9f8fe..3b14b09 100644
--- a/pkg/analyzer/test/src/dart/resolution/type_inference/type_test_expressions_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/type_inference/type_test_expressions_test.dart
@@ -9,14 +9,16 @@
main() {
defineReflectiveSuite(() {
defineReflectiveTests(IsNotTest);
- defineReflectiveTests(IsNotWithNullSafetyTest);
+ defineReflectiveTests(IsNotWithoutNullSafetyTest);
defineReflectiveTests(IsTest);
- defineReflectiveTests(IsWithNullSafetyTest);
+ defineReflectiveTests(IsWithoutNullSafetyTest);
});
}
@reflectiveTest
-class IsNotTest extends PubPackageResolutionTest with WithoutNullSafetyMixin {
+class IsNotTest extends PubPackageResolutionTest with IsNotTestCases {}
+
+mixin IsNotTestCases on PubPackageResolutionTest {
test_simple() async {
await resolveTestCode('''
void f(Object a) {
@@ -29,10 +31,13 @@
}
@reflectiveTest
-class IsNotWithNullSafetyTest extends IsNotTest with WithNullSafetyMixin {}
+class IsNotWithoutNullSafetyTest extends PubPackageResolutionTest
+ with IsNotTestCases, WithoutNullSafetyMixin {}
@reflectiveTest
-class IsTest extends PubPackageResolutionTest with WithoutNullSafetyMixin {
+class IsTest extends PubPackageResolutionTest with IsTestCases {}
+
+mixin IsTestCases on PubPackageResolutionTest {
test_simple() async {
await resolveTestCode('''
void f(Object a) {
@@ -45,4 +50,5 @@
}
@reflectiveTest
-class IsWithNullSafetyTest extends IsTest with WithNullSafetyMixin {}
+class IsWithoutNullSafetyTest extends PubPackageResolutionTest
+ with IsTestCases, WithoutNullSafetyMixin {}
diff --git a/pkg/analyzer/test/src/diagnostics/ambiguous_set_or_map_literal_test.dart b/pkg/analyzer/test/src/diagnostics/ambiguous_set_or_map_literal_test.dart
index 30de480..de079aa 100644
--- a/pkg/analyzer/test/src/diagnostics/ambiguous_set_or_map_literal_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/ambiguous_set_or_map_literal_test.dart
@@ -10,15 +10,59 @@
main() {
defineReflectiveSuite(() {
defineReflectiveTests(AmbiguousSetOrMapLiteralBothTest);
- defineReflectiveTests(AmbiguousSetOrMapLiteralBothWithNullSafetyTest);
+ defineReflectiveTests(AmbiguousSetOrMapLiteralBothWithoutNullSafetyTest);
defineReflectiveTests(AmbiguousSetOrMapLiteralEitherTest);
- defineReflectiveTests(AmbiguousSetOrMapLiteralEitherWithNullSafetyTest);
+ defineReflectiveTests(AmbiguousSetOrMapLiteralEitherWithoutNullSafetyTest);
});
}
@reflectiveTest
class AmbiguousSetOrMapLiteralBothTest extends PubPackageResolutionTest
- with WithoutNullSafetyMixin {
+ with AmbiguousSetOrMapLiteralBothTestCases {
+ test_map_keyNonNullable_valueNullable() async {
+ await assertNoErrorsInCode('''
+f(Map<int, int?> map) {
+ return {...map};
+}
+''');
+ }
+
+ test_map_keyNullable_valueNonNullable() async {
+ await assertNoErrorsInCode('''
+f(Map<int?, int> map) {
+ return {...map};
+}
+''');
+ }
+
+ test_map_keyNullable_valueNullable() async {
+ await assertNoErrorsInCode('''
+f(Map<int?, int?> map) {
+ return {...map};
+}
+''');
+ }
+
+ test_set_elementNullable() async {
+ await assertNoErrorsInCode('''
+f(Set<int?> set) {
+ return {...set};
+}
+''');
+ }
+
+ test_setAndMap_nullable() async {
+ await assertErrorsInCode('''
+f(Map<int?, int> map, Set<int?> set) {
+ return {...set, ...map};
+}
+''', [
+ error(CompileTimeErrorCode.AMBIGUOUS_SET_OR_MAP_LITERAL_BOTH, 48, 16),
+ ]);
+ }
+}
+
+mixin AmbiguousSetOrMapLiteralBothTestCases on PubPackageResolutionTest {
test_map() async {
await assertNoErrorsInCode('''
f(Map<int, int> map) {
@@ -63,54 +107,15 @@
}
@reflectiveTest
-class AmbiguousSetOrMapLiteralBothWithNullSafetyTest
- extends AmbiguousSetOrMapLiteralBothTest with WithNullSafetyMixin {
- test_map_keyNonNullable_valueNullable() async {
- await assertNoErrorsInCode('''
-f(Map<int, int?> map) {
- return {...map};
-}
-''');
- }
-
- test_map_keyNullable_valueNonNullable() async {
- await assertNoErrorsInCode('''
-f(Map<int?, int> map) {
- return {...map};
-}
-''');
- }
-
- test_map_keyNullable_valueNullable() async {
- await assertNoErrorsInCode('''
-f(Map<int?, int?> map) {
- return {...map};
-}
-''');
- }
-
- test_set_elementNullable() async {
- await assertNoErrorsInCode('''
-f(Set<int?> set) {
- return {...set};
-}
-''');
- }
-
- test_setAndMap_nullable() async {
- await assertErrorsInCode('''
-f(Map<int?, int> map, Set<int?> set) {
- return {...set, ...map};
-}
-''', [
- error(CompileTimeErrorCode.AMBIGUOUS_SET_OR_MAP_LITERAL_BOTH, 48, 16),
- ]);
- }
-}
+class AmbiguousSetOrMapLiteralBothWithoutNullSafetyTest
+ extends PubPackageResolutionTest
+ with AmbiguousSetOrMapLiteralBothTestCases, WithoutNullSafetyMixin {}
@reflectiveTest
class AmbiguousSetOrMapLiteralEitherTest extends PubPackageResolutionTest
- with WithoutNullSafetyMixin {
+ with AmbiguousSetOrMapLiteralEitherTestCases {}
+
+mixin AmbiguousSetOrMapLiteralEitherTestCases on PubPackageResolutionTest {
test_invalidPrefixOperator() async {
// Guard against an exception being thrown.
await assertErrorsInCode('''
@@ -132,5 +137,6 @@
}
@reflectiveTest
-class AmbiguousSetOrMapLiteralEitherWithNullSafetyTest
- extends AmbiguousSetOrMapLiteralEitherTest with WithNullSafetyMixin {}
+class AmbiguousSetOrMapLiteralEitherWithoutNullSafetyTest
+ extends PubPackageResolutionTest
+ with AmbiguousSetOrMapLiteralEitherTestCases, WithoutNullSafetyMixin {}