dart-sdk/pkg/vm_service/test/breakpoint_two_args_checked_test.dart
Ben Konyi 76a74ba678 [ package:vm_service ] Migrate Observatory service tests to package:vm_service (Pt 1)
See https://github.com/dart-lang/sdk/issues/45037

TEST=pkg/vm_service/test/*

Change-Id: I20bfc03ae40bc41ee4d965a71f090ecf974e4e59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185522
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-11-05 17:04:07 +00:00

88 lines
2.3 KiB
Dart

// Copyright (c) 2016, 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=--verbose_debug
// TODO(bkonyi): consider deleting now that DBC is no more.
// This test was mostly interesting for DBC, which needed to patch two bytecodes
// to create a breakpoint for fast Smi ops.
import 'dart:developer';
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 LINE_A = 29;
const int LINE_B = 30;
const int LINE_C = 31;
class NotGeneric {}
testeeMain() {
final x = List<dynamic>.filled(1, null);
final y = 7;
debugger();
print("Statement");
x[0] = 3; // Line A.
x is NotGeneric; // Line B.
y & 4; // Line C.
}
final tests = <IsolateTest>[
hasStoppedAtBreakpoint,
// Add breakpoints.
(VmService service, IsolateRef isolateRef) async {
final isolateId = isolateRef.id!;
final isolate = await service.getIsolate(isolateId);
Library rootLib =
await service.getObject(isolateId, isolate.rootLib!.id!) as Library;
final script =
await service.getObject(isolateId, rootLib.scripts![0].id!) as Script;
final scriptId = script.id!;
final bpt1 = await service.addBreakpoint(isolateId, scriptId, LINE_A);
print(bpt1);
expect(bpt1.resolved, isTrue);
expect(script.getLineNumberFromTokenPos(bpt1.location!.tokenPos),
equals(LINE_A));
final bpt2 = await service.addBreakpoint(isolateId, scriptId, LINE_B);
print(bpt2);
expect(bpt2.resolved, isTrue);
expect(script.getLineNumberFromTokenPos(bpt2.location!.tokenPos),
equals(LINE_B));
final bpt3 = await service.addBreakpoint(isolateId, scriptId, LINE_C);
print(bpt3);
expect(bpt3.resolved, isTrue);
expect(script.getLineNumberFromTokenPos(bpt3.location!.tokenPos),
equals(LINE_C));
},
resumeIsolate,
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_A),
resumeIsolate,
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_B),
resumeIsolate,
hasStoppedAtBreakpoint,
stoppedAtLine(LINE_C),
resumeIsolate,
];
main(args) => runIsolateTests(
args,
tests,
'breakpoint_two_args_checked_test.dart',
testeeConcurrent: testeeMain,
);