blob: a780623642be9700d4eb0acfe523b8b2a46ddb95 [file]
// Copyright (c) 2025, 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.
// Regression test for https://dartbug.com/57048.
import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
import 'common/service_test_common.dart';
import 'evaluate_uninitialized_late_variable_lib.dart' as testee_lib;
void main([args = const <String>[]]) {
IsolateTestHarness(
'evaluate_uninitialized_late_variable_lib.dart',
args,
)
.hasStoppedAtBreakpoint()
.stoppedAtLine('LINE_A')
.addCustomTest((VmService service, IsolateRef isolateRef) async {
final isolateId = isolateRef.id!;
try {
print(await service.evaluateInFrame(isolateId, 0, 'x.a'));
fail('Expected evaluateInFrame to throw an RPCError');
} on RPCError catch (e) {
// TODO(57048): We currently pretend that uninitialized late variables
// don't exist to avoid crashing when evaluating expressions that need to
// access the late variables' values. The CFE team is working on a better
// solution.
expect(e.code, RPCErrorKind.kExpressionCompilationError.code);
expect(e.message, contains('Expression compilation error'));
expect(
e.details,
contains("Error: The variable 'x' "
'is unavailable in this expression evaluation.'),
);
}
}).run(testeeMain: testee_lib.main);
}