[VM/Service] Add test that steps through an inline class method call with the debugger

TEST=CI

Fixes https://github.com/dart-lang/sdk/issues/49746
Change-Id: I2637efeb53856466a47611b28a91d5d6828ecdc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292380
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Derek Xu 2023-04-03 14:59:00 +00:00 committed by Commit Queue
parent 57ba99c2d3
commit d947cd69ef

View file

@ -0,0 +1,71 @@
// Copyright (c) 2023, 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.
// VMOptions=--enable-experiment=inline-class
// @dart=3.0
// ignore_for_file: experiment_not_enabled
import 'package:test/test.dart';
import 'package:vm_service/vm_service.dart';
import 'common/service_test_common.dart';
import 'common/test_helper.dart';
const int testMainStartLine = 27;
const int inlineClassDefinitionStartLine = 19;
const String fileName = 'step_through_inline_class_method_call_test.dart';
inline class IdNumber {
final int i;
IdNumber(this.i);
operator <(IdNumber other) => i < other.i;
}
testMain() {
IdNumber id1 = IdNumber(123);
IdNumber id2 = IdNumber(999);
id1 < id2;
}
List<String> stops = [];
List<String> expected = [
'$fileName:${testMainStartLine + 0}:9', // on '()'
'$fileName:${testMainStartLine + 1}:18', // on 'IdNumber'
'$fileName:${testMainStartLine + 2}:18', // on 'IdNumber'
'$fileName:${testMainStartLine + 3}:7', // on '<'
'$fileName:${inlineClassDefinitionStartLine + 5}:23', // on 'other'
'$fileName:${inlineClassDefinitionStartLine + 5}:35', // on '<'
'$fileName:${inlineClassDefinitionStartLine + 5}:33', // on 'i'
'$fileName:${testMainStartLine + 4}:1', // on closing '}' of [testMain]
];
final tests = <IsolateTest>[
hasPausedAtStart,
setBreakpointAtLine(testMainStartLine),
(VmService service, IsolateRef isolateRef) async {
final isolateId = isolateRef.id!;
final isolate = await service.getIsolate(isolateId);
final Library rootLib =
(await service.getObject(isolateId, isolate.rootLib!.id!)) as Library;
final FuncRef function =
rootLib.functions!.firstWhere((f) => f.name == 'IdNumber|<');
expect(function, isNotNull);
await service.addBreakpointAtEntry(isolateId, function.id!);
},
runStepThroughProgramRecordingStops(stops),
checkRecordedStops(stops, expected),
];
main(args) => runIsolateTestsSynchronous(
args,
tests,
fileName,
testeeConcurrent: testMain,
extraArgs: extraDebuggingArgs,
pause_on_start: true,
pause_on_exit: true,
);