Analyzer: Refactor and rename test classes in 18 files to use TestCases model
The diffs may look large, but only due to sorting. No tests were added, removed, or altered. Change-Id: Id126e9a08056f6d3f99bad32d7060d65b07e4e90 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209722 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
7ff8c6c6be
commit
19fa4519bd
@@ -18,8 +18,7 @@ main() {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class NullSafetyExperimentGlobalTest extends _FeaturesTest
|
||||
with WithNullSafetyMixin {
|
||||
class NullSafetyExperimentGlobalTest extends _FeaturesTest {
|
||||
test_jsonConfig_legacyContext_nonNullDependency() async {
|
||||
_configureTestWithJsonConfig('''
|
||||
{
|
||||
|
||||
@@ -9,13 +9,25 @@ import '../context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(LocalVariableTest);
|
||||
defineReflectiveTests(LocalVariableWithNullSafetyTest);
|
||||
defineReflectiveTests(LocalVariableWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class LocalVariableTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with LocalVariableTestCases {
|
||||
test_Never() async {
|
||||
await resolveTestCode('''
|
||||
void f(Never a) {
|
||||
var v = a;
|
||||
v;
|
||||
}
|
||||
''');
|
||||
_assertTypeOfV('Never');
|
||||
}
|
||||
}
|
||||
|
||||
mixin LocalVariableTestCases on PubPackageResolutionTest {
|
||||
test_int() async {
|
||||
await resolveTestCode('''
|
||||
void f() {
|
||||
@@ -43,15 +55,5 @@ void f() {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class LocalVariableWithNullSafetyTest extends LocalVariableTest
|
||||
with WithNullSafetyMixin {
|
||||
test_Never() async {
|
||||
await resolveTestCode('''
|
||||
void f(Never a) {
|
||||
var v = a;
|
||||
v;
|
||||
}
|
||||
''');
|
||||
_assertTypeOfV('Never');
|
||||
}
|
||||
}
|
||||
class LocalVariableWithoutNullSafetyTest extends PubPackageResolutionTest
|
||||
with LocalVariableTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -10,13 +10,63 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(MissingEnumConstantInSwitchTest);
|
||||
defineReflectiveTests(MissingEnumConstantInSwitchWithNullSafetyTest);
|
||||
defineReflectiveTests(MissingEnumConstantInSwitchWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class MissingEnumConstantInSwitchTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with MissingEnumConstantInSwitchTestCases {
|
||||
test_nullable() async {
|
||||
await assertErrorsInCode('''
|
||||
enum E { one, two }
|
||||
|
||||
void f(E? e) {
|
||||
switch (e) {
|
||||
case E.one:
|
||||
case E.two:
|
||||
break;
|
||||
}
|
||||
}
|
||||
''', [
|
||||
error(StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH, 38, 10),
|
||||
]);
|
||||
}
|
||||
|
||||
test_nullable_default() async {
|
||||
await assertNoErrorsInCode('''
|
||||
enum E { one, two }
|
||||
|
||||
void f(E? e) {
|
||||
switch (e) {
|
||||
case E.one:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_nullable_null() async {
|
||||
await assertNoErrorsInCode('''
|
||||
enum E { one, two }
|
||||
|
||||
void f(E? e) {
|
||||
switch (e) {
|
||||
case E.one:
|
||||
break;
|
||||
case E.two:
|
||||
break;
|
||||
case null:
|
||||
break;
|
||||
}
|
||||
}
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
||||
mixin MissingEnumConstantInSwitchTestCases on PubPackageResolutionTest {
|
||||
test_default() async {
|
||||
await assertNoErrorsInCode('''
|
||||
enum E { one, two, three }
|
||||
@@ -99,53 +149,6 @@ void f(E e) {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class MissingEnumConstantInSwitchWithNullSafetyTest
|
||||
extends MissingEnumConstantInSwitchTest with WithNullSafetyMixin {
|
||||
test_nullable() async {
|
||||
await assertErrorsInCode('''
|
||||
enum E { one, two }
|
||||
|
||||
void f(E? e) {
|
||||
switch (e) {
|
||||
case E.one:
|
||||
case E.two:
|
||||
break;
|
||||
}
|
||||
}
|
||||
''', [
|
||||
error(StaticWarningCode.MISSING_ENUM_CONSTANT_IN_SWITCH, 38, 10),
|
||||
]);
|
||||
}
|
||||
|
||||
test_nullable_default() async {
|
||||
await assertNoErrorsInCode('''
|
||||
enum E { one, two }
|
||||
|
||||
void f(E? e) {
|
||||
switch (e) {
|
||||
case E.one:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_nullable_null() async {
|
||||
await assertNoErrorsInCode('''
|
||||
enum E { one, two }
|
||||
|
||||
void f(E? e) {
|
||||
switch (e) {
|
||||
case E.one:
|
||||
break;
|
||||
case E.two:
|
||||
break;
|
||||
case null:
|
||||
break;
|
||||
}
|
||||
}
|
||||
''');
|
||||
}
|
||||
}
|
||||
class MissingEnumConstantInSwitchWithoutNullSafetyTest
|
||||
extends PubPackageResolutionTest
|
||||
with MissingEnumConstantInSwitchTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -10,13 +10,23 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(MixinOfNonClassTest);
|
||||
defineReflectiveTests(MixinOfNonClassWithNullSafetyTest);
|
||||
defineReflectiveTests(MixinOfNonClassWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class MixinOfNonClassTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with MixinOfNonClassTestCases {
|
||||
test_Never() async {
|
||||
await assertErrorsInCode('''
|
||||
class A with Never {}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.MIXIN_OF_NON_CLASS, 13, 5),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
mixin MixinOfNonClassTestCases on PubPackageResolutionTest {
|
||||
test_class() async {
|
||||
await assertErrorsInCode(r'''
|
||||
int A = 7;
|
||||
@@ -165,13 +175,5 @@ class C with p.M {}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class MixinOfNonClassWithNullSafetyTest extends MixinOfNonClassTest
|
||||
with WithNullSafetyMixin {
|
||||
test_Never() async {
|
||||
await assertErrorsInCode('''
|
||||
class A with Never {}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.MIXIN_OF_NON_CLASS, 13, 5),
|
||||
]);
|
||||
}
|
||||
}
|
||||
class MixinOfNonClassWithoutNullSafetyTest extends PubPackageResolutionTest
|
||||
with MixinOfNonClassTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
+2
-8
@@ -10,18 +10,12 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(MixinSuperClassConstraintNonInterfaceTest);
|
||||
defineReflectiveTests(
|
||||
MixinSuperClassConstraintNonInterfaceWithNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class MixinSuperClassConstraintNonInterfaceTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {}
|
||||
|
||||
@reflectiveTest
|
||||
class MixinSuperClassConstraintNonInterfaceWithNullSafetyTest
|
||||
extends MixinSuperClassConstraintNonInterfaceTest with WithNullSafetyMixin {
|
||||
class MixinSuperClassConstraintNonInterfaceTest
|
||||
extends PubPackageResolutionTest {
|
||||
test_Never() async {
|
||||
await assertErrorsInCode('''
|
||||
mixin M on Never {}
|
||||
|
||||
@@ -10,13 +10,15 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(NonConstantCaseExpressionTest);
|
||||
defineReflectiveTests(NonConstantCaseExpressionWithNullSafetyTest);
|
||||
defineReflectiveTests(NonConstantCaseExpressionWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class NonConstantCaseExpressionTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with NonConstantCaseExpressionTestCases {}
|
||||
|
||||
mixin NonConstantCaseExpressionTestCases on PubPackageResolutionTest {
|
||||
test_constField() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
void f(C e) {
|
||||
@@ -66,5 +68,6 @@ void f(var e) {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class NonConstantCaseExpressionWithNullSafetyTest
|
||||
extends NonConstantCaseExpressionTest with WithNullSafetyMixin {}
|
||||
class NonConstantCaseExpressionWithoutNullSafetyTest
|
||||
extends PubPackageResolutionTest
|
||||
with NonConstantCaseExpressionTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -10,13 +10,13 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(NotMapSpreadTest);
|
||||
defineReflectiveTests(NotMapSpreadNullSafetyTest);
|
||||
defineReflectiveTests(NotMapSpreadWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class NotMapSpreadNullSafetyTest extends NotMapSpreadTest
|
||||
with WithNullSafetyMixin {
|
||||
class NotMapSpreadTest extends PubPackageResolutionTest
|
||||
with NotMapSpreadTestCases {
|
||||
test_map_typeParameter_bound_mapQuestion() async {
|
||||
await assertNoErrorsInCode('''
|
||||
void f<T extends Map<int, String>?>(T a) {
|
||||
@@ -27,9 +27,7 @@ void f<T extends Map<int, String>?>(T a) {
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class NotMapSpreadTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
mixin NotMapSpreadTestCases on PubPackageResolutionTest {
|
||||
test_map() async {
|
||||
await assertNoErrorsInCode('''
|
||||
var a = {0: 0};
|
||||
@@ -100,3 +98,7 @@ void f<T extends num>(T a) {
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class NotMapSpreadWithoutNullSafetyTest extends PubPackageResolutionTest
|
||||
with NotMapSpreadTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
+38
-34
@@ -10,13 +10,46 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(ReturnOfInvalidTypeForCatchErrorTest);
|
||||
defineReflectiveTests(ReturnOfInvalidTypeForCatchErrorWithNullSafetyTest);
|
||||
defineReflectiveTests(
|
||||
ReturnOfInvalidTypeForCatchErrorWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class ReturnOfInvalidTypeForCatchErrorTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with ReturnOfInvalidTypeForCatchErrorTestCases {
|
||||
test_nullableType_emptyBody() async {
|
||||
await assertNoErrorsInCode('''
|
||||
void f(Future<int?> future) {
|
||||
future.catchError((e, st) {});
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_nullableType_emptyReturn() async {
|
||||
await assertErrorsInCode('''
|
||||
void f(Future<int?> future) {
|
||||
future.catchError((e, st) {
|
||||
return;
|
||||
});
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.RETURN_WITHOUT_VALUE, 64, 6),
|
||||
]);
|
||||
}
|
||||
|
||||
test_nullableType_invalidReturnType() async {
|
||||
await assertErrorsInCode('''
|
||||
void f(Future<int?> future) {
|
||||
future.catchError((e, st) => '');
|
||||
}
|
||||
''', [
|
||||
error(HintCode.RETURN_OF_INVALID_TYPE_FROM_CATCH_ERROR, 61, 2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
mixin ReturnOfInvalidTypeForCatchErrorTestCases on PubPackageResolutionTest {
|
||||
test_async_okReturnType() async {
|
||||
await assertNoErrorsInCode('''
|
||||
void f(Future<int> future) {
|
||||
@@ -167,35 +200,6 @@ void f(Future<int> future, void Function() g) {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class ReturnOfInvalidTypeForCatchErrorWithNullSafetyTest
|
||||
extends ReturnOfInvalidTypeForCatchErrorTest with WithNullSafetyMixin {
|
||||
test_nullableType_emptyBody() async {
|
||||
await assertNoErrorsInCode('''
|
||||
void f(Future<int?> future) {
|
||||
future.catchError((e, st) {});
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_nullableType_emptyReturn() async {
|
||||
await assertErrorsInCode('''
|
||||
void f(Future<int?> future) {
|
||||
future.catchError((e, st) {
|
||||
return;
|
||||
});
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.RETURN_WITHOUT_VALUE, 64, 6),
|
||||
]);
|
||||
}
|
||||
|
||||
test_nullableType_invalidReturnType() async {
|
||||
await assertErrorsInCode('''
|
||||
void f(Future<int?> future) {
|
||||
future.catchError((e, st) => '');
|
||||
}
|
||||
''', [
|
||||
error(HintCode.RETURN_OF_INVALID_TYPE_FROM_CATCH_ERROR, 61, 2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
class ReturnOfInvalidTypeForCatchErrorWithoutNullSafetyTest
|
||||
extends PubPackageResolutionTest
|
||||
with ReturnOfInvalidTypeForCatchErrorTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -11,13 +11,85 @@ main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(ReturnOfInvalidTypeTest);
|
||||
defineReflectiveTests(ReturnOfInvalidTypeWithNoImplicitCastsTest);
|
||||
defineReflectiveTests(ReturnOfInvalidTypeWithNullSafetyTest);
|
||||
defineReflectiveTests(ReturnOfInvalidTypeWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class ReturnOfInvalidTypeTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with ReturnOfInvalidTypeTestCases {
|
||||
test_function_async_block_int__to_Future_void() async {
|
||||
await assertErrorsInCode(r'''
|
||||
Future<void> f() async {
|
||||
return 0;
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION, 34, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_function_async_block_void__to_Future_Null() async {
|
||||
await assertErrorsInCode(r'''
|
||||
Future<Null> f(void a) async {
|
||||
return a;
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION, 40, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_function_async_block_void__to_FutureOr_ObjectQ() async {
|
||||
await assertErrorsInCode(r'''
|
||||
import 'dart:async';
|
||||
|
||||
FutureOr<Object?> f(void a) async {
|
||||
return a;
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION, 67, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_function_async_expression_dynamic__to_Future_int() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
Future<int> f(dynamic a) async => a;
|
||||
''');
|
||||
}
|
||||
|
||||
test_functionExpression_async_futureOr_void__to_Object() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
void a = null;
|
||||
|
||||
Object Function() f = () async {
|
||||
return a;
|
||||
};
|
||||
''');
|
||||
}
|
||||
|
||||
test_functionExpression_async_futureQ_void__to_Object() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
Future<void>? a = (throw 0);
|
||||
|
||||
Object Function() f = () async {
|
||||
return a;
|
||||
};
|
||||
''');
|
||||
}
|
||||
|
||||
test_functionExpression_async_void__to_FutureOr_ObjectQ() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
import 'dart:async';
|
||||
|
||||
void a = (throw 0);
|
||||
|
||||
FutureOr<Object?> Function() f = () async {
|
||||
return a;
|
||||
};
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
||||
mixin ReturnOfInvalidTypeTestCases on PubPackageResolutionTest {
|
||||
test_closure() async {
|
||||
await assertErrorsInCode('''
|
||||
typedef Td = int Function();
|
||||
@@ -415,75 +487,5 @@ Future<List<String>> f() async {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class ReturnOfInvalidTypeWithNullSafetyTest extends ReturnOfInvalidTypeTest
|
||||
with WithNullSafetyMixin {
|
||||
test_function_async_block_int__to_Future_void() async {
|
||||
await assertErrorsInCode(r'''
|
||||
Future<void> f() async {
|
||||
return 0;
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION, 34, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_function_async_block_void__to_Future_Null() async {
|
||||
await assertErrorsInCode(r'''
|
||||
Future<Null> f(void a) async {
|
||||
return a;
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION, 40, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_function_async_block_void__to_FutureOr_ObjectQ() async {
|
||||
await assertErrorsInCode(r'''
|
||||
import 'dart:async';
|
||||
|
||||
FutureOr<Object?> f(void a) async {
|
||||
return a;
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.RETURN_OF_INVALID_TYPE_FROM_FUNCTION, 67, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_function_async_expression_dynamic__to_Future_int() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
Future<int> f(dynamic a) async => a;
|
||||
''');
|
||||
}
|
||||
|
||||
test_functionExpression_async_futureOr_void__to_Object() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
void a = null;
|
||||
|
||||
Object Function() f = () async {
|
||||
return a;
|
||||
};
|
||||
''');
|
||||
}
|
||||
|
||||
test_functionExpression_async_futureQ_void__to_Object() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
Future<void>? a = (throw 0);
|
||||
|
||||
Object Function() f = () async {
|
||||
return a;
|
||||
};
|
||||
''');
|
||||
}
|
||||
|
||||
test_functionExpression_async_void__to_FutureOr_ObjectQ() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
import 'dart:async';
|
||||
|
||||
void a = (throw 0);
|
||||
|
||||
FutureOr<Object?> Function() f = () async {
|
||||
return a;
|
||||
};
|
||||
''');
|
||||
}
|
||||
}
|
||||
class ReturnOfInvalidTypeWithoutNullSafetyTest extends PubPackageResolutionTest
|
||||
with ReturnOfInvalidTypeTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -10,13 +10,25 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(ReturnTypeInvalidForCatchErrorTest);
|
||||
defineReflectiveTests(ReturnTypeInvalidForCatchErrorWithNullSafetyTest);
|
||||
defineReflectiveTests(ReturnTypeInvalidForCatchErrorWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class ReturnTypeInvalidForCatchErrorTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with ReturnTypeInvalidForCatchErrorTestCases {
|
||||
test_nullableReturnType() async {
|
||||
await assertErrorsInCode('''
|
||||
void f(Future<int> future, String? Function(dynamic, StackTrace) cb) {
|
||||
future.catchError(cb);
|
||||
}
|
||||
''', [
|
||||
error(HintCode.RETURN_TYPE_INVALID_FOR_CATCH_ERROR, 91, 2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
mixin ReturnTypeInvalidForCatchErrorTestCases on PubPackageResolutionTest {
|
||||
test_dynamic_returnTypeIsUnrelatedFuture() async {
|
||||
await assertNoErrorsInCode('''
|
||||
void f(
|
||||
@@ -87,15 +99,6 @@ void f(Future<void> future, String Function(dynamic, StackTrace) cb) {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class ReturnTypeInvalidForCatchErrorWithNullSafetyTest
|
||||
extends ReturnTypeInvalidForCatchErrorTest with WithNullSafetyMixin {
|
||||
test_nullableReturnType() async {
|
||||
await assertErrorsInCode('''
|
||||
void f(Future<int> future, String? Function(dynamic, StackTrace) cb) {
|
||||
future.catchError(cb);
|
||||
}
|
||||
''', [
|
||||
error(HintCode.RETURN_TYPE_INVALID_FOR_CATCH_ERROR, 91, 2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
class ReturnTypeInvalidForCatchErrorWithoutNullSafetyTest
|
||||
extends PubPackageResolutionTest
|
||||
with ReturnTypeInvalidForCatchErrorTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -10,13 +10,15 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(ReturnWithoutValueTest);
|
||||
defineReflectiveTests(ReturnWithoutValueWithNullSafetyTest);
|
||||
defineReflectiveTests(ReturnWithoutValueWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class ReturnWithoutValueTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with ReturnWithoutValueTestCases {}
|
||||
|
||||
mixin ReturnWithoutValueTestCases on PubPackageResolutionTest {
|
||||
test_async_futureInt() async {
|
||||
await assertErrorsInCode('''
|
||||
Future<int> f() async {
|
||||
@@ -163,5 +165,5 @@ int f(int x) {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class ReturnWithoutValueWithNullSafetyTest extends ReturnWithoutValueTest
|
||||
with WithNullSafetyMixin {}
|
||||
class ReturnWithoutValueWithoutNullSafetyTest extends PubPackageResolutionTest
|
||||
with ReturnWithoutValueTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -11,25 +11,12 @@ import 'sdk_constraint_verifier_support.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(SdkVersionNeverTest);
|
||||
defineReflectiveTests(SdkVersionNeverWithNullSafetyTest);
|
||||
defineReflectiveTests(SdkVersionNeverWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class SdkVersionNeverTest extends SdkConstraintVerifierTest
|
||||
with WithoutNullSafetyMixin {
|
||||
test_languageVersionBeforeNullSafety() async {
|
||||
await verifyVersion('2.7.0', r'''
|
||||
Never foo;
|
||||
''', expectedErrors: [
|
||||
error(HintCode.SDK_VERSION_NEVER, 0, 5),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class SdkVersionNeverWithNullSafetyTest extends SdkConstraintVerifierTest
|
||||
with WithNullSafetyMixin {
|
||||
class SdkVersionNeverTest extends SdkConstraintVerifierTest {
|
||||
test_experimentEnabled() async {
|
||||
await verifyVersion('2.7.0', r'''
|
||||
Never foo = (throw 42);
|
||||
@@ -45,3 +32,15 @@ Never foo = (throw 42);
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class SdkVersionNeverWithoutNullSafetyTest extends SdkConstraintVerifierTest
|
||||
with WithoutNullSafetyMixin {
|
||||
test_languageVersionBeforeNullSafety() async {
|
||||
await verifyVersion('2.7.0', r'''
|
||||
Never foo;
|
||||
''', expectedErrors: [
|
||||
error(HintCode.SDK_VERSION_NEVER, 0, 5),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,16 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(TypeParameterSupertypeOfItsBoundTest);
|
||||
defineReflectiveTests(TypeParameterSupertypeOfItsBoundWithNullSafetyTest);
|
||||
defineReflectiveTests(
|
||||
TypeParameterSupertypeOfItsBoundWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class TypeParameterSupertypeOfItsBoundTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with TypeParameterSupertypeOfItsBoundTestCases {}
|
||||
|
||||
mixin TypeParameterSupertypeOfItsBoundTestCases on PubPackageResolutionTest {
|
||||
test_1of1() async {
|
||||
await assertErrorsInCode(r'''
|
||||
class A<T extends T> {
|
||||
@@ -50,5 +53,6 @@ class A<T1 extends T3, T2, T3 extends T1> {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class TypeParameterSupertypeOfItsBoundWithNullSafetyTest
|
||||
extends TypeParameterSupertypeOfItsBoundTest with WithNullSafetyMixin {}
|
||||
class TypeParameterSupertypeOfItsBoundWithoutNullSafetyTest
|
||||
extends PubPackageResolutionTest
|
||||
with TypeParameterSupertypeOfItsBoundTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -10,13 +10,15 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(UndefinedHiddenNameTest);
|
||||
defineReflectiveTests(UndefinedHiddenNameWithNullSafetyTest);
|
||||
defineReflectiveTests(UndefinedHiddenNameWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class UndefinedHiddenNameTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with UndefinedHiddenNameTestCases {}
|
||||
|
||||
mixin UndefinedHiddenNameTestCases on PubPackageResolutionTest {
|
||||
test_export() async {
|
||||
newFile('$testPackageLibPath/lib1.dart');
|
||||
await assertErrorsInCode(r'''
|
||||
@@ -38,5 +40,5 @@ import 'lib1.dart' hide a;
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class UndefinedHiddenNameWithNullSafetyTest extends UndefinedHiddenNameTest
|
||||
with WithNullSafetyMixin {}
|
||||
class UndefinedHiddenNameWithoutNullSafetyTest extends PubPackageResolutionTest
|
||||
with UndefinedHiddenNameTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -11,13 +11,38 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(UndefinedIdentifierTest);
|
||||
defineReflectiveTests(UndefinedIdentifierWithNullSafetyTest);
|
||||
defineReflectiveTests(UndefinedIdentifierWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class UndefinedIdentifierTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with UndefinedIdentifierTestCases {
|
||||
test_get_from_external_variable_final_valid() async {
|
||||
await assertNoErrorsInCode('''
|
||||
external final int x;
|
||||
int f() => x;
|
||||
''');
|
||||
}
|
||||
|
||||
test_get_from_external_variable_valid() async {
|
||||
await assertNoErrorsInCode('''
|
||||
external int x;
|
||||
int f() => x;
|
||||
''');
|
||||
}
|
||||
|
||||
test_set_external_variable_valid() async {
|
||||
await assertNoErrorsInCode('''
|
||||
external int x;
|
||||
void f(int value) {
|
||||
x = value;
|
||||
}
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
||||
mixin UndefinedIdentifierTestCases on PubPackageResolutionTest {
|
||||
test_annotation_favors_scope_resolution_over_this_resolution_class() async {
|
||||
// If an annotation on a class type parameter cannot be resolved using the
|
||||
// normal scope resolution mechanism, it is resolved via implicit `this`.
|
||||
@@ -397,28 +422,5 @@ void f(int p) {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class UndefinedIdentifierWithNullSafetyTest extends UndefinedIdentifierTest
|
||||
with WithNullSafetyMixin {
|
||||
test_get_from_external_variable_final_valid() async {
|
||||
await assertNoErrorsInCode('''
|
||||
external final int x;
|
||||
int f() => x;
|
||||
''');
|
||||
}
|
||||
|
||||
test_get_from_external_variable_valid() async {
|
||||
await assertNoErrorsInCode('''
|
||||
external int x;
|
||||
int f() => x;
|
||||
''');
|
||||
}
|
||||
|
||||
test_set_external_variable_valid() async {
|
||||
await assertNoErrorsInCode('''
|
||||
external int x;
|
||||
void f(int value) {
|
||||
x = value;
|
||||
}
|
||||
''');
|
||||
}
|
||||
}
|
||||
class UndefinedIdentifierWithoutNullSafetyTest extends PubPackageResolutionTest
|
||||
with UndefinedIdentifierTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -10,13 +10,15 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(UndefinedShownNameTest);
|
||||
defineReflectiveTests(UndefinedShownNameWithNullSafetyTest);
|
||||
defineReflectiveTests(UndefinedShownNameWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class UndefinedShownNameTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with UndefinedShownNameTestCases {}
|
||||
|
||||
mixin UndefinedShownNameTestCases on PubPackageResolutionTest {
|
||||
test_export() async {
|
||||
newFile('$testPackageLibPath/lib1.dart');
|
||||
await assertErrorsInCode(r'''
|
||||
@@ -38,5 +40,5 @@ import 'lib1.dart' show a;
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class UndefinedShownNameWithNullSafetyTest extends UndefinedShownNameTest
|
||||
with WithNullSafetyMixin {}
|
||||
class UndefinedShownNameWithoutNullSafetyTest extends PubPackageResolutionTest
|
||||
with UndefinedShownNameTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -10,15 +10,36 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(UnnecessaryTypeCheckFalseTest);
|
||||
defineReflectiveTests(UnnecessaryTypeCheckFalseWithNullSafetyTest);
|
||||
defineReflectiveTests(UnnecessaryTypeCheckFalseWithoutNullSafetyTest);
|
||||
defineReflectiveTests(UnnecessaryTypeCheckTrueTest);
|
||||
defineReflectiveTests(UnnecessaryTypeCheckTrueWithNullSafetyTest);
|
||||
defineReflectiveTests(UnnecessaryTypeCheckTrueWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class UnnecessaryTypeCheckFalseTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with UnnecessaryTypeCheckFalseTestCases {
|
||||
@override
|
||||
test_type_not_object() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
void f<T>(T a) {
|
||||
a is! Object;
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_type_not_objectQuestion() async {
|
||||
await assertErrorsInCode(r'''
|
||||
void f<T>(T a) {
|
||||
a is! Object?;
|
||||
}
|
||||
''', [
|
||||
error(HintCode.UNNECESSARY_TYPE_CHECK_FALSE, 19, 13),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
mixin UnnecessaryTypeCheckFalseTestCases on PubPackageResolutionTest {
|
||||
test_null_not_Null() async {
|
||||
await assertErrorsInCode(r'''
|
||||
var b = null is! Null;
|
||||
@@ -49,31 +70,34 @@ void f<T>(T a) {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class UnnecessaryTypeCheckFalseWithNullSafetyTest
|
||||
extends UnnecessaryTypeCheckFalseTest with WithNullSafetyMixin {
|
||||
class UnnecessaryTypeCheckFalseWithoutNullSafetyTest
|
||||
extends PubPackageResolutionTest
|
||||
with UnnecessaryTypeCheckFalseTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@reflectiveTest
|
||||
class UnnecessaryTypeCheckTrueTest extends PubPackageResolutionTest
|
||||
with UnnecessaryTypeCheckTrueTestCases {
|
||||
@override
|
||||
test_type_not_object() async {
|
||||
test_type_is_object() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
void f<T>(T a) {
|
||||
a is! Object;
|
||||
a is Object;
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_type_not_objectQuestion() async {
|
||||
test_type_is_objectQuestion() async {
|
||||
await assertErrorsInCode(r'''
|
||||
void f<T>(T a) {
|
||||
a is! Object?;
|
||||
a is Object?;
|
||||
}
|
||||
''', [
|
||||
error(HintCode.UNNECESSARY_TYPE_CHECK_FALSE, 19, 13),
|
||||
error(HintCode.UNNECESSARY_TYPE_CHECK_TRUE, 19, 12),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class UnnecessaryTypeCheckTrueTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
mixin UnnecessaryTypeCheckTrueTestCases on PubPackageResolutionTest {
|
||||
test_null_is_Null() async {
|
||||
await assertErrorsInCode(r'''
|
||||
var b = null is Null;
|
||||
@@ -104,24 +128,6 @@ void f<T>(T a) {
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class UnnecessaryTypeCheckTrueWithNullSafetyTest
|
||||
extends UnnecessaryTypeCheckTrueTest with WithNullSafetyMixin {
|
||||
@override
|
||||
test_type_is_object() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
void f<T>(T a) {
|
||||
a is Object;
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_type_is_objectQuestion() async {
|
||||
await assertErrorsInCode(r'''
|
||||
void f<T>(T a) {
|
||||
a is Object?;
|
||||
}
|
||||
''', [
|
||||
error(HintCode.UNNECESSARY_TYPE_CHECK_TRUE, 19, 12),
|
||||
]);
|
||||
}
|
||||
}
|
||||
class UnnecessaryTypeCheckTrueWithoutNullSafetyTest
|
||||
extends PubPackageResolutionTest
|
||||
with UnnecessaryTypeCheckTrueTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
@@ -10,13 +10,15 @@ import '../dart/resolution/context_collection_resolution.dart';
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(YieldOfInvalidTypeTest);
|
||||
defineReflectiveTests(YieldOfInvalidTypeWithNullSafetyTest);
|
||||
defineReflectiveTests(YieldOfInvalidTypeWithoutNullSafetyTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class YieldOfInvalidTypeTest extends PubPackageResolutionTest
|
||||
with WithoutNullSafetyMixin {
|
||||
with YieldOfInvalidTypeTestCases {}
|
||||
|
||||
mixin YieldOfInvalidTypeTestCases on PubPackageResolutionTest {
|
||||
test_none_asyncStar_dynamic_to_streamInt() async {
|
||||
await assertErrorsInCode(
|
||||
'''
|
||||
@@ -448,5 +450,5 @@ Iterable<String> g() => throw 0;
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class YieldOfInvalidTypeWithNullSafetyTest extends YieldOfInvalidTypeTest
|
||||
with WithNullSafetyMixin {}
|
||||
class YieldOfInvalidTypeWithoutNullSafetyTest extends PubPackageResolutionTest
|
||||
with YieldOfInvalidTypeTestCases, WithoutNullSafetyMixin {}
|
||||
|
||||
Reference in New Issue
Block a user