-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VM/Compiler] Mark instructions related to late initialization error …
…checks as synthetic TEST=pkg/vm_service/test/breakpoints_ignore_late_initialization_error_instructions_test.dart Fixes: #53376 Change-Id: Iab7d2489f29bfc4a586b9de6e3caa0a7c1a35454 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355000 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Derek Xu <derekx@google.com>
- Loading branch information
Showing
2 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
pkg/vm_service/test/breakpoints_ignore_late_initialization_error_instructions_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright (c) 2024, 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. | ||
|
||
// Regression test for https://dartbug.com/53376. | ||
|
||
import 'common/service_test_common.dart'; | ||
import 'common/test_helper.dart'; | ||
|
||
const String shortFile = | ||
'breakpoints_ignore_late_initialization_error_instructions_test.dart'; | ||
|
||
// AUTOGENERATED START | ||
// | ||
// Update these constants by running: | ||
// | ||
// dart pkg/vm_service/test/update_line_numbers.dart <test.dart> | ||
// | ||
const LINE_A = 33; | ||
const LINE_B = 42; | ||
const LINE_C = 51; | ||
// AUTOGENERATED END | ||
|
||
int getThree() => 3; | ||
|
||
void testeeMain() { | ||
// ignore: prefer_final_locals | ||
late int x = 1; | ||
// When a late variable is read, the VM performs checks to ensure that the | ||
// variable has been initialized. When a breakpoint is set on the following | ||
// line, it should resolve to the [toDouble] call instruction, not to an | ||
// instruction part of the late variable initialization checks. | ||
final double xd = x.toDouble(); // LINE_A | ||
print(xd); | ||
|
||
late final int y = 2; | ||
// When a late final variable is read, the VM performs checks to ensure that | ||
// the variable has been assigned a value exactly once. When a breakpoint is | ||
// set on the following line, it should resolve to the [toDouble] call | ||
// instruction, not to an instruction part of the late variable assignment | ||
// checks. | ||
final double yd = y.toDouble(); // LINE_B | ||
print(yd); | ||
|
||
late final int z; | ||
// When a late final variable is assigned a value, the VM performs checks to | ||
// ensure that the variable has not already been initialized. When a | ||
// breakpoint is set on the following line, it should resolve to the | ||
// [getThree] call instruction, not to an instruction part of the late | ||
// variable initialization checks. | ||
z = getThree(); // LINE_C | ||
print(z); | ||
} | ||
|
||
List<String> stops = []; | ||
|
||
const List<String> expected = [ | ||
'$shortFile:$LINE_A:23', // on 'toDouble' | ||
'$shortFile:$LINE_B:23', // on 'toDouble' | ||
'$shortFile:$LINE_C:7', // on 'getThree' | ||
]; | ||
|
||
final tests = <IsolateTest>[ | ||
hasPausedAtStart, | ||
setBreakpointAtLine(LINE_A), | ||
setBreakpointAtLine(LINE_B), | ||
setBreakpointAtLine(LINE_C), | ||
resumeProgramRecordingStops(stops, false), | ||
checkRecordedStops(stops, expected), | ||
]; | ||
|
||
Future<void> main([args = const <String>[]]) => runIsolateTests( | ||
args, | ||
tests, | ||
shortFile, | ||
testeeConcurrent: testeeMain, | ||
pauseOnStart: true, | ||
pauseOnExit: true, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters