|
| 1 | +// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file |
| 2 | +// for details. All rights reserved. Use of this source code is governed by a |
| 3 | +// BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +// VMOptions=--enable-experiment=inline-class |
| 6 | +// @dart=3.0 |
| 7 | +// ignore_for_file: experiment_not_enabled |
| 8 | + |
| 9 | +import 'package:test/test.dart'; |
| 10 | +import 'package:vm_service/vm_service.dart'; |
| 11 | + |
| 12 | +import 'common/service_test_common.dart'; |
| 13 | +import 'common/test_helper.dart'; |
| 14 | + |
| 15 | +const int testMainStartLine = 27; |
| 16 | +const int inlineClassDefinitionStartLine = 19; |
| 17 | +const String fileName = 'step_through_inline_class_method_call_test.dart'; |
| 18 | + |
| 19 | +inline class IdNumber { |
| 20 | + final int i; |
| 21 | + |
| 22 | + IdNumber(this.i); |
| 23 | + |
| 24 | + operator <(IdNumber other) => i < other.i; |
| 25 | +} |
| 26 | + |
| 27 | +testMain() { |
| 28 | + IdNumber id1 = IdNumber(123); |
| 29 | + IdNumber id2 = IdNumber(999); |
| 30 | + id1 < id2; |
| 31 | +} |
| 32 | + |
| 33 | +List<String> stops = []; |
| 34 | + |
| 35 | +List<String> expected = [ |
| 36 | + '$fileName:${testMainStartLine + 0}:9', // on '()' |
| 37 | + '$fileName:${testMainStartLine + 1}:18', // on 'IdNumber' |
| 38 | + '$fileName:${testMainStartLine + 2}:18', // on 'IdNumber' |
| 39 | + '$fileName:${testMainStartLine + 3}:7', // on '<' |
| 40 | + '$fileName:${inlineClassDefinitionStartLine + 5}:23', // on 'other' |
| 41 | + '$fileName:${inlineClassDefinitionStartLine + 5}:35', // on '<' |
| 42 | + '$fileName:${inlineClassDefinitionStartLine + 5}:33', // on 'i' |
| 43 | + '$fileName:${testMainStartLine + 4}:1', // on closing '}' of [testMain] |
| 44 | +]; |
| 45 | + |
| 46 | +final tests = <IsolateTest>[ |
| 47 | + hasPausedAtStart, |
| 48 | + setBreakpointAtLine(testMainStartLine), |
| 49 | + (VmService service, IsolateRef isolateRef) async { |
| 50 | + final isolateId = isolateRef.id!; |
| 51 | + final isolate = await service.getIsolate(isolateId); |
| 52 | + final Library rootLib = |
| 53 | + (await service.getObject(isolateId, isolate.rootLib!.id!)) as Library; |
| 54 | + final FuncRef function = |
| 55 | + rootLib.functions!.firstWhere((f) => f.name == 'IdNumber|<'); |
| 56 | + expect(function, isNotNull); |
| 57 | + await service.addBreakpointAtEntry(isolateId, function.id!); |
| 58 | + }, |
| 59 | + runStepThroughProgramRecordingStops(stops), |
| 60 | + checkRecordedStops(stops, expected), |
| 61 | +]; |
| 62 | + |
| 63 | +main(args) => runIsolateTestsSynchronous( |
| 64 | + args, |
| 65 | + tests, |
| 66 | + fileName, |
| 67 | + testeeConcurrent: testMain, |
| 68 | + extraArgs: extraDebuggingArgs, |
| 69 | + pause_on_start: true, |
| 70 | + pause_on_exit: true, |
| 71 | + ); |
0 commit comments