diff --git a/VM/declaring_constructors_t01.dart b/VM/declaring_constructors_t01.dart deleted file mode 100644 index e514d47233..0000000000 --- a/VM/declaring_constructors_t01.dart +++ /dev/null @@ -1,166 +0,0 @@ -// 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 A declaring constructor declaration is a declaration that -/// contains a `` with a -/// ``, or a declaration that contains a -/// ``, or it is a -/// `` in the header of a class, enum, or extension -/// type declaration, together with a declaration in the body that contains a -/// ``. -/// -/// @description Check that declaring constructors invocation and declaration -/// can be debugged. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=declaring-constructors - -import 'dart:developer'; -import 'package:vm_service/vm_service.dart'; - -import '../../../../pkg/vm_service/test/common/service_test_common.dart'; -import '../../../../pkg/vm_service/test/common/test_helper.dart'; -import '../Utils/expect.dart'; - -const String shortFile = 'declaring_constructors_t01.dart'; - -// AUTOGENERATED START -// -// Update these constants by running: -// -// dart pkg/vm_service/test/update_line_numbers.dart tests/co19/src/VM/declaring_constructors_t01.dart -// -const LINE_A = 44; -const LINE_B = 47; -const LINE_C = 53; -const LINE_D = 59; -const LINE_E = 64; -const LINE_F = 65; -const LINE_G = 66; -const LINE_H = 67; -// AUTOGENERATED END - -class C1(var int v1, final int v2); // LINE_A - -class C2 { - this(var int v1, final int v2); // LINE_B -} - -class C3(int v1, int v2) { - int v1; - final int v2; - this: v1 = v1, v2 = v2; // LINE_C -} - -class C4 { - int v1; - final int v2; - this(int v1, int v2) : v1 = v1, v2 = v2; // LINE_D -} - -void testeeMain() { - debugger(); - var c1 = C1(1, 2); // LINE_E - var c2 = C2(3, 4); // LINE_F - var c3 = C3(5, 6); // LINE_G - var c4 = C4(7, 8); // LINE_H -} - -List stops = []; - -const List expected = [ - '$shortFile:$LINE_E:10', // on '=' - '$shortFile:$LINE_E:12', // on 'C1' - '$shortFile:$LINE_A:32', // on 'v2' - '$shortFile:$LINE_A:35', // on ';' - '$shortFile:$LINE_F:10', // on '=' - '$shortFile:$LINE_F:12', // on 'C2' - '$shortFile:$LINE_B:30', // on 'v2' - '$shortFile:$LINE_B:33', // on ';' - '$shortFile:$LINE_G:10', // on '=' - '$shortFile:$LINE_G:12', // on 'C3' - '$shortFile:$LINE_C:18', // on 'v2' - '$shortFile:$LINE_C:25', // on ';' - '$shortFile:$LINE_H:10', // on '=' - '$shortFile:$LINE_H:12', // on 'C4' - '$shortFile:$LINE_D:35', // on 'v2' - '$shortFile:$LINE_D:42', // on ';' -]; - -final tests = [ - hasStoppedAtBreakpoint, - - // Test interaction of expression evaluation with declaring constructors invocation - (VmService service, IsolateRef isolateRef) async { - final isolateId = isolateRef.id!; - - InstanceRef response = - await service.evaluateInFrame(isolateId, 0, 'C1(1, 2).v1') - as InstanceRef; - Expect.equals('1', response.valueAsString); - - response = - await service.evaluateInFrame(isolateId, 0, 'C2(3, 4).v2') - as InstanceRef; - Expect.equals('4', response.valueAsString); - - response = - await service.evaluateInFrame(isolateId, 0, 'C3(5, 6).v1') - as InstanceRef; - Expect.equals('5', response.valueAsString); - - response = - await service.evaluateInFrame(isolateId, 0, 'C4(7, 8).v2') - as InstanceRef; - Expect.equals('8', response.valueAsString); - }, - - // Test interaction of breakpoints with declaring constructors. - (VmService service, IsolateRef isolateRef) async { - final isolateId = isolateRef.id!; - final isolate = await service.getIsolate(isolateId); - final lib = - (await service.getObject(isolateId, isolate.rootLib!.id!)) as Library; - final scriptId = lib.scripts!.first.id!; - - var breakpoint = await service.addBreakpoint(isolateId, scriptId, LINE_E); - var (_, (line, column)) = await breakpoint.getLocation(service, isolateRef); - Expect.isTrue(breakpoint.enabled); - Expect.equals(LINE_E, line); - Expect.equals(10, column); // on '=' - - breakpoint = await service.addBreakpoint(isolateId, scriptId, LINE_F); - var (_, (line, column)) = await breakpoint.getLocation(service, isolateRef); - Expect.isTrue(breakpoint.enabled); - Expect.equals(LINE_F, line); - Expect.equals(10, column); // on '=' - await service.removeBreakpoint(isolateId, breakpoint.id!); - - breakpoint = await service.addBreakpoint(isolateId, scriptId, LINE_G); - var (_, (line, column)) = await breakpoint.getLocation(service, isolateRef); - Expect.isTrue(breakpoint.enabled); - Expect.equals(LINE_G, line); - Expect.equals(10, column); // on '=' - await service.removeBreakpoint(isolateId, breakpoint.id!); - - breakpoint = await service.addBreakpoint(isolateId, scriptId, LINE_H); - var (_, (line, column)) = await breakpoint.getLocation(service, isolateRef); - Expect.isTrue(breakpoint.enabled); - Expect.equals(LINE_H, line); - Expect.equals(10, column); // on '=' - await service.removeBreakpoint(isolateId, breakpoint.id!); - }, - - // Test interaction of single-stepping with declaring constructors. - runStepIntoThroughProgramRecordingStops(stops), - checkRecordedStops(stops, expected), -]; - -void main([args = const []]) => runIsolateTests( - args, - tests, - 'declaring_constructors_t01.dart', - pauseOnExit: true, - testeeConcurrent: testeeMain, -); diff --git a/VM/primary_constructors_t01.dart b/VM/primary_constructors_t01.dart new file mode 100644 index 0000000000..a403a91c02 --- /dev/null +++ b/VM/primary_constructors_t01.dart @@ -0,0 +1,115 @@ +// 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 A primary constructor declaration consists of a +/// `` in the declaration header plus optionally a member +/// declaration in the body that starts with a +/// ``. +/// +/// @description Check that primary constructors invocation and declaration +/// can be debugged. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=primary-constructors + +import 'dart:developer'; +import 'package:vm_service/vm_service.dart'; + +import '../../../../pkg/vm_service/test/common/service_test_common.dart'; +import '../../../../pkg/vm_service/test/common/test_helper.dart'; +import '../Utils/expect.dart'; + +const String shortFile = 'primary_constructors_t01.dart'; + +// AUTOGENERATED START +// +// Update these constants by running: +// +// dart pkg/vm_service/test/update_line_numbers.dart tests/co19/src/VM/primary_constructors_t01.dart +// +const LINE_A = 40; +const LINE_B = 45; +const LINE_C = 50; +const LINE_D = 51; +// AUTOGENERATED END + +class C1(var int v1, final int v2); // LINE_A + +class C2(int v1, int v2) { + int v1; + final int v2; + this: v1 = v1, v2 = v2; // LINE_B +} + +void testeeMain() { + debugger(); + var c1 = C1(1, 2); // LINE_C + var c2 = C2(5, 6); // LINE_D +} + +List stops = []; + +const List expected = [ + '$shortFile:$LINE_C:10', // on '=' + '$shortFile:$LINE_C:12', // on 'C1' + '$shortFile:$LINE_A:32', // on 'v2' + '$shortFile:$LINE_A:35', // on ';' + '$shortFile:$LINE_D:10', // on '=' + '$shortFile:$LINE_D:12', // on 'C2' + '$shortFile:$LINE_B:18', // on 'v2' + '$shortFile:$LINE_B:25', // on ';' +]; + +final tests = [ + hasStoppedAtBreakpoint, + + // Test interaction of expression evaluation with invocation of primary constructors + (VmService service, IsolateRef isolateRef) async { + final isolateId = isolateRef.id!; + + InstanceRef response = + await service.evaluateInFrame(isolateId, 0, 'C1(1, 2).v1') + as InstanceRef; + Expect.equals('1', response.valueAsString); + + response = + await service.evaluateInFrame(isolateId, 0, 'C2(3, 4).v1') + as InstanceRef; + Expect.equals('3', response.valueAsString); + }, + + // Test interaction of breakpoints with primary constructors. + (VmService service, IsolateRef isolateRef) async { + final isolateId = isolateRef.id!; + final isolate = await service.getIsolate(isolateId); + final lib = + (await service.getObject(isolateId, isolate.rootLib!.id!)) as Library; + final scriptId = lib.scripts!.first.id!; + + var breakpoint = await service.addBreakpoint(isolateId, scriptId, LINE_C); + var (_, (line, column)) = await breakpoint.getLocation(service, isolateRef); + Expect.isTrue(breakpoint.enabled); + Expect.equals(LINE_C, line); + Expect.equals(10, column); // on '=' + + breakpoint = await service.addBreakpoint(isolateId, scriptId, LINE_D); + (_, (line, column)) = await breakpoint.getLocation(service, isolateRef); + Expect.isTrue(breakpoint.enabled); + Expect.equals(LINE_D, line); + Expect.equals(10, column); // on '=' + await service.removeBreakpoint(isolateId, breakpoint.id!); + }, + + // Test interaction of single-stepping with primary constructors. + runStepIntoThroughProgramRecordingStops(stops), + checkRecordedStops(stops, expected), +]; + +void main([args = const []]) => runIsolateTests( + args, + tests, + 'primary_constructors_t01.dart', + pauseOnExit: true, + testeeConcurrent: testeeMain, +); diff --git a/VM/declaring_constructors_t02.dart b/VM/primary_constructors_t02.dart similarity index 51% rename from VM/declaring_constructors_t02.dart rename to VM/primary_constructors_t02.dart index 1f66d663b4..e3b5ab0ac8 100644 --- a/VM/declaring_constructors_t02.dart +++ b/VM/primary_constructors_t02.dart @@ -2,19 +2,16 @@ // 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 A declaring constructor declaration is a declaration that -/// contains a `` with a -/// ``, or a declaration that contains a -/// ``, or it is a -/// `` in the header of a class, enum, or extension -/// type declaration, together with a declaration in the body that contains a -/// ``. +/// @assertion A primary constructor declaration consists of a +/// `` in the declaration header plus optionally a member +/// declaration in the body that starts with a +/// ``. /// /// @description Check that members initialized in primary initializer scope can /// be debugged. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=declaring-constructors +// SharedOptions=--enable-experiment=primary-constructors import 'dart:developer'; import 'package:vm_service/vm_service.dart'; @@ -23,38 +20,31 @@ import '../../../../pkg/vm_service/test/common/service_test_common.dart'; import '../../../../pkg/vm_service/test/common/test_helper.dart'; import '../Utils/expect.dart'; -const String shortFile = 'declaring_constructors_t03.dart'; +const String shortFile = 'primary_constructors_t02.dart'; // AUTOGENERATED START // // Update these constants by running: // -// dart pkg/vm_service/test/update_line_numbers.dart tests/co19/src/VM/declaring_constructors_t02.dart +// dart pkg/vm_service/test/update_line_numbers.dart tests/co19/src/VM/primary_constructors_t02.dart // -const LINE_A = 41; -const LINE_B = 44; -const LINE_C = 48; -const LINE_D = 49; -const LINE_E = 50; +const LINE_A = 39; +const LINE_B = 42; +const LINE_C = 43; // AUTOGENERATED END class C1(var String x); // LINE_A -class C2 { - this(final String x); // LINE_B -} - void testeeMain() { - debugger(); // LINE_C - C1("xxx"); // LINE_D - C2("yyy"); // LINE_E + debugger(); // LINE_B + C1("xxx"); // LINE_C } final tests = [ hasStoppedAtBreakpoint, - stoppedAtLine(LINE_C), + stoppedAtLine(LINE_B), stepInto, - stoppedAtLine(LINE_D), + stoppedAtLine(LINE_C), stepInto, stoppedAtLine(LINE_A), (VmService service, IsolateRef isolateRef) async { @@ -76,35 +66,12 @@ final tests = [ await service.evaluateInFrame(isolateId, 0, 'this.x') as InstanceRef; Expect.equals('xxx', xRef2.valueAsString); }, - stepInto, - stoppedAtLine(LINE_E), - stepInto, - stoppedAtLine(LINE_B), - (VmService service, IsolateRef isolateRef) async { - final isolateId = isolateRef.id!; - final xRef1 = - await service.evaluateInFrame(isolateId, 0, 'x') as InstanceRef; - Expect.equals("null", xRef1.valueAsString); - final xRef2 = - await service.evaluateInFrame(isolateId, 0, 'this.x') as InstanceRef; - Expect.equals("null", xRef2.valueAsString); - }, - stepInto, - (VmService service, IsolateRef isolateRef) async { - final isolateId = isolateRef.id!; - final xRef1 = - await service.evaluateInFrame(isolateId, 0, 'x') as InstanceRef; - Expect.equals('yyy', xRef1.valueAsString); - final xRef2 = - await service.evaluateInFrame(isolateId, 0, 'this.x') as InstanceRef; - Expect.equals('yyy', xRef2.valueAsString); - }, ]; void main([args = const []]) => runIsolateTests( args, tests, - 'declaring_constructors_t02.dart', + 'primary_constructors_t02.dart', pauseOnExit: true, testeeConcurrent: testeeMain, ); diff --git a/VM/private_named_parameters_t01.dart b/VM/private_named_parameters_t01.dart index 567a815035..9b6fb7bf26 100644 --- a/VM/private_named_parameters_t01.dart +++ b/VM/private_named_parameters_t01.dart @@ -9,7 +9,7 @@ /// @description Check that private named parameters can be debugged. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=declaring-constructors,private-named-parameters +// SharedOptions=--enable-experiment=primary-constructors,private-named-parameters import 'dart:developer'; import 'package:vm_service/vm_service.dart'; diff --git a/VM/private_named_parameters_t02.dart b/VM/private_named_parameters_t02.dart index 0cf618b501..f6e1260a92 100644 --- a/VM/private_named_parameters_t02.dart +++ b/VM/private_named_parameters_t02.dart @@ -10,7 +10,7 @@ /// expression evaluation. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=declaring-constructors,private-named-parameters +// SharedOptions=--enable-experiment=primary-constructors,private-named-parameters import 'dart:developer';