blob: ee1ca43eb3305a0130eff71185177530199c516a [file] [edit]
// 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.
/// @assertion We let users use a private name in a named parameter when the
/// parameter also initializes or declares a field. The compiler removes the `_`
/// from the argument name but keeps it for the corresponding field.
///
/// @description Check that private named parameters are allowed in VM
/// expression evaluation.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=primary-constructors,private-named-parameters
import 'dart:developer';
import 'package:vm_service/vm_service.dart';
import '../../../../pkg/vm_service/test/common/service_test_common.dart';
import '../Utils/expect.dart';
import 'private_named_parameters_t02_lib.dart' as testee_lib;
void main([
args = const <String>[],
]) => IsolateTestHarness('private_named_parameters_t02_lib.dart', args)
.hasStoppedAtBreakpoint()
// Test interaction of expression evaluation with private named parameters.
.addCustomTest((VmService service, IsolateRef isolateRef) async {
final isolateId = isolateRef.id!;
InstanceRef response =
await service.evaluateInFrame(isolateId, 0, 'c1._x') as InstanceRef;
Expect.equals('one', response.valueAsString);
response =
await service.evaluateInFrame(isolateId, 0, 'c2._x') as InstanceRef;
Expect.equals('two', response.valueAsString);
response = await service.evaluateInFrame(
isolateId,
0,
'C1(x: "zero")._x',
) as InstanceRef;
Expect.equals('zero', response.valueAsString);
response = await service.evaluateInFrame(
isolateId,
0,
'C2(x: "0")._x',
) as InstanceRef;
Expect.equals('0', response.valueAsString);
})
.run(
pauseOnExit: true,
extraArgs: [
'--enable-experiment=primary-constructors',
'--enable-experiment=private-named-parameters',
],
testeeMain: testee_lib.main,
);