From 69e2623f4c3ed8461a2a5563da3d410fa4ec20ff Mon Sep 17 00:00:00 2001 From: "Sergey G. Grekhov" Date: Tue, 18 Nov 2025 14:28:08 +0200 Subject: [PATCH 1/2] #3315. Updated VM tests for primary constructors --- ...t01.dart => primary_constructors_t01.dart} | 98 +++++-------------- ...t02.dart => primary_constructors_t02.dart} | 52 +++------- VM/private_named_parameters_t01.dart | 2 +- VM/private_named_parameters_t02.dart | 2 +- 4 files changed, 38 insertions(+), 116 deletions(-) rename VM/{declaring_constructors_t01.dart => primary_constructors_t01.dart} (54%) rename VM/{declaring_constructors_t02.dart => primary_constructors_t02.dart} (64%) diff --git a/VM/declaring_constructors_t01.dart b/VM/primary_constructors_t01.dart similarity index 54% rename from VM/declaring_constructors_t01.dart rename to VM/primary_constructors_t01.dart index e514d47233..ca7baa4206 100644 --- a/VM/declaring_constructors_t01.dart +++ b/VM/primary_constructors_t01.dart @@ -14,7 +14,7 @@ /// 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,69 +23,45 @@ 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'; +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/declaring_constructors_t01.dart +// dart pkg/vm_service/test/update_line_numbers.dart tests/co19/src/VM/primary_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; +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 { - 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 { +class C2(int v1, int v2) { int v1; final int v2; - this(int v1, int v2) : v1 = v1, v2 = v2; // LINE_D + this: v1 = v1, v2 = v2; // LINE_B } 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 + var c1 = C1(1, 2); // LINE_C + var c2 = C2(5, 6); // LINE_D } List stops = []; const List expected = [ - '$shortFile:$LINE_E:10', // on '=' - '$shortFile:$LINE_E:12', // on 'C1' + '$shortFile:$LINE_C:10', // on '=' + '$shortFile:$LINE_C: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 ';' + '$shortFile:$LINE_D:10', // on '=' + '$shortFile:$LINE_D:12', // on 'C2' + '$shortFile:$LINE_B:18', // on 'v2' + '$shortFile:$LINE_B:25', // on ';' ]; final tests = [ @@ -101,19 +77,9 @@ final tests = [ 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') + await service.evaluateInFrame(isolateId, 0, 'C2(3, 4).v1') as InstanceRef; - Expect.equals('8', response.valueAsString); + Expect.equals('3', response.valueAsString); }, // Test interaction of breakpoints with declaring constructors. @@ -124,30 +90,16 @@ final tests = [ (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 breakpoint = await service.addBreakpoint(isolateId, scriptId, LINE_C); var (_, (line, column)) = await breakpoint.getLocation(service, isolateRef); Expect.isTrue(breakpoint.enabled); - Expect.equals(LINE_E, line); + Expect.equals(LINE_C, 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); + breakpoint = await service.addBreakpoint(isolateId, scriptId, LINE_D); + (_, (line, column)) = await breakpoint.getLocation(service, isolateRef); Expect.isTrue(breakpoint.enabled); - Expect.equals(LINE_H, line); + Expect.equals(LINE_D, line); Expect.equals(10, column); // on '=' await service.removeBreakpoint(isolateId, breakpoint.id!); }, @@ -160,7 +112,7 @@ final tests = [ void main([args = const []]) => runIsolateTests( args, tests, - 'declaring_constructors_t01.dart', + 'primary_constructors_t01.dart', pauseOnExit: true, testeeConcurrent: testeeMain, ); diff --git a/VM/declaring_constructors_t02.dart b/VM/primary_constructors_t02.dart similarity index 64% rename from VM/declaring_constructors_t02.dart rename to VM/primary_constructors_t02.dart index 1f66d663b4..8df92f0f41 100644 --- a/VM/declaring_constructors_t02.dart +++ b/VM/primary_constructors_t02.dart @@ -14,7 +14,7 @@ /// 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 +23,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 +69,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'; From 60bc74f438dff24b005c1647eeef736bcaab3137 Mon Sep 17 00:00:00 2001 From: "Sergey G. Grekhov" Date: Tue, 18 Nov 2025 18:01:24 +0200 Subject: [PATCH 2/2] Fix comments and assertions --- VM/primary_constructors_t01.dart | 19 ++++++++----------- VM/primary_constructors_t02.dart | 11 ++++------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/VM/primary_constructors_t01.dart b/VM/primary_constructors_t01.dart index ca7baa4206..a403a91c02 100644 --- a/VM/primary_constructors_t01.dart +++ b/VM/primary_constructors_t01.dart @@ -2,15 +2,12 @@ // 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 declaring constructors invocation and declaration +/// @description Check that primary constructors invocation and declaration /// can be debugged. /// @author sgrekhov22@gmail.com @@ -67,7 +64,7 @@ const List expected = [ final tests = [ hasStoppedAtBreakpoint, - // Test interaction of expression evaluation with declaring constructors invocation + // Test interaction of expression evaluation with invocation of primary constructors (VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; @@ -82,7 +79,7 @@ final tests = [ Expect.equals('3', response.valueAsString); }, - // Test interaction of breakpoints with declaring constructors. + // Test interaction of breakpoints with primary constructors. (VmService service, IsolateRef isolateRef) async { final isolateId = isolateRef.id!; final isolate = await service.getIsolate(isolateId); @@ -104,7 +101,7 @@ final tests = [ await service.removeBreakpoint(isolateId, breakpoint.id!); }, - // Test interaction of single-stepping with declaring constructors. + // Test interaction of single-stepping with primary constructors. runStepIntoThroughProgramRecordingStops(stops), checkRecordedStops(stops, expected), ]; diff --git a/VM/primary_constructors_t02.dart b/VM/primary_constructors_t02.dart index 8df92f0f41..e3b5ab0ac8 100644 --- a/VM/primary_constructors_t02.dart +++ b/VM/primary_constructors_t02.dart @@ -2,13 +2,10 @@ // 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.