CQ. Migrate from assertInvalidTestCode() to resolveTestCodeWithDiagnostics() and remove it.

Change-Id: Id1306cef4434ee4f61fa3df8a33aa4009698203f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510189
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov
2026-06-09 12:34:43 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent b5eb9af663
commit f8d286d4d2
4 changed files with 27 additions and 15 deletions
@@ -147,8 +147,10 @@ MethodInvocation
}
test_invalid_inDefaultValue_nullAware() async {
var result = await assertInvalidTestCode(r'''
var result = await resolveTestCodeWithDiagnostics(r'''
void f({a = b?[0]}) {}
// ^
// [diag.undefinedIdentifier] Undefined name 'b'.
''');
// TODO(scheglov): https://github.com/dart-lang/sdk/issues/49101
@@ -172,8 +174,12 @@ IndexExpression
}
test_invalid_inDefaultValue_nullAware2() async {
var result = await assertInvalidTestCode(r'''
var result = await resolveTestCodeWithDiagnostics(r'''
typedef void F({a = b?[0]});
// ^
// [diag.defaultValueInFunctionType] Parameters in a function type can't have default values.
// ^
// [diag.undefinedIdentifier] Undefined name 'b'.
''');
var node = result.findNode.index('[0]');
@@ -5727,8 +5727,10 @@ MethodInvocation
}
test_invalid_inDefaultValue_nullAware() async {
var result = await assertInvalidTestCode('''
var result = await resolveTestCodeWithDiagnostics('''
void f({a = b?.foo()}) {}
// ^
// [diag.undefinedIdentifier] Undefined name 'b'.
''');
var node = result.findNode.methodInvocation('?.foo()');
@@ -5752,8 +5754,12 @@ MethodInvocation
}
test_invalid_inDefaultValue_nullAware2() async {
var result = await assertInvalidTestCode('''
var result = await resolveTestCodeWithDiagnostics('''
typedef void F({a = b?.foo()});
// ^
// [diag.defaultValueInFunctionType] Parameters in a function type can't have default values.
// ^
// [diag.undefinedIdentifier] Undefined name 'b'.
''');
var node = result.findNode.methodInvocation('?.foo()');
@@ -656,8 +656,10 @@ AssignmentExpression
}
test_invalid_inDefaultValue_nullAware() async {
var result = await assertInvalidTestCode('''
var result = await resolveTestCodeWithDiagnostics('''
void f({a = b?.foo}) {}
// ^
// [diag.undefinedIdentifier] Undefined name 'b'.
''');
var node = result.findNode.singlePropertyAccess;
@@ -677,8 +679,12 @@ PropertyAccess
}
test_invalid_inDefaultValue_nullAware2() async {
var result = await assertInvalidTestCode('''
var result = await resolveTestCodeWithDiagnostics('''
typedef void F({a = b?.foo});
// ^
// [diag.defaultValueInFunctionType] Parameters in a function type can't have default values.
// ^
// [diag.undefinedIdentifier] Undefined name 'b'.
''');
var node = result.findNode.singlePropertyAccess;
@@ -698,8 +704,10 @@ PropertyAccess
}
test_invalid_inDefaultValue_nullAware_cascade() async {
var result = await assertInvalidTestCode('''
var result = await resolveTestCodeWithDiagnostics('''
void f({a = b?..foo}) {}
// ^
// [diag.undefinedIdentifier] Undefined name 'b'.
''');
var node = result.findNode.singleFormalParameter;
@@ -133,14 +133,6 @@ mixin ResolutionTest implements ResourceProviderMixin {
expect(result.diagnostics, isNotEmpty);
}
/// Resolve the [code], and ensure that it can be resolved without a crash,
/// and is invalid, i.e. produces a diagnostic.
Future<TestResolvedUnitResult> assertInvalidTestCode(String code) async {
var result = await resolveTestCode(code);
expect(result.diagnostics, isNotEmpty);
return result;
}
void assertParsedNodeText(AstNode node, String expected) {
var buffer = StringBuffer();
var sink = TreeStringSink(sink: buffer, indent: '');