blob: 35b4f577ddcac5786d13780de2f950c0a59132ab [file] [log] [blame]
// Copyright (c) 2015, 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.
import 'dart:developer';
import 'package:test/test.dart';
import 'package:observatory/service_io.dart';
import 'service_test_common.dart';
import 'test_helper.dart';
// AUTOGENERATED START
//
// Update these constants by running:
//
// dart pkg/vm_service/test/update_line_numbers.dart runtime/observatory/tests/service/debugging_inlined_finally_test.dart
//
const LINE_A = 32;
const LINE_B = 35;
const LINE_C = 38;
// AUTOGENERATED END
testFunction() {
debugger();
var a;
try {
var b;
try {
for (int i = 0; i < 10;) {
var x = () => i + a + b;
return x; // LINE_A
}
} finally {
b = 10; // LINE_B
}
} finally {
a = 1; // LINE_C
}
}
testMain() {
var f = testFunction();
expect(f(), equals(11));
}
var tests = <IsolateTest>[
hasStoppedAtBreakpoint,
// Add breakpoint
(Isolate isolate) async {
await isolate.rootLibrary.load();
var script = isolate.rootLibrary.scripts[0];
await script.load();
// Add 3 breakpoints.
{
var result = await isolate.addBreakpoint(script, LINE_A);
Breakpoint bpt = result;
expect(bpt.type, equals('Breakpoint'));
expect(bpt.location!.script!.id, equals(script.id));
expect(bpt.location!.script!.tokenToLine(bpt.location!.tokenPos),
equals(LINE_A));
expect(isolate.breakpoints.length, equals(1));
}
{
var result = await isolate.addBreakpoint(script, LINE_B);
Breakpoint bpt = result;
expect(bpt.type, equals('Breakpoint'));
expect(bpt.location!.script!.id, equals(script.id));
expect(bpt.location!.script!.tokenToLine(bpt.location!.tokenPos),
equals(LINE_B));
expect(isolate.breakpoints.length, equals(2));
}
{
var result = await isolate.addBreakpoint(script, LINE_C);
Breakpoint bpt = result;
expect(bpt.type, equals('Breakpoint'));
expect(bpt.location!.script!.id, equals(script.id));
expect(bpt.location!.script!.tokenToLine(bpt.location!.tokenPos),
equals(LINE_C));
expect(isolate.breakpoints.length, equals(3));
}
// Wait for breakpoint events.
},
resumeIsolate,
hasStoppedAtBreakpoint,
// We are at the breakpoint on line LINE_A.
(Isolate isolate) async {
ServiceMap stack = await isolate.getStack();
expect(stack.type, equals('Stack'));
expect(stack['frames'].length, greaterThanOrEqualTo(1));
Script script = stack['frames'][0].location.script;
expect(script.tokenToLine(stack['frames'][0].location.tokenPos),
equals(LINE_A));
},
resumeIsolate,
hasStoppedAtBreakpoint,
// We are at the breakpoint on line LINE_B.
(Isolate isolate) async {
ServiceMap stack = await isolate.getStack();
expect(stack.type, equals('Stack'));
expect(stack['frames'].length, greaterThanOrEqualTo(1));
Script script = stack['frames'][0].location.script;
expect(script.tokenToLine(stack['frames'][0].location.tokenPos),
equals(LINE_B));
},
resumeIsolate,
hasStoppedAtBreakpoint,
// We are at the breakpoint on line LINE_C.
(Isolate isolate) async {
ServiceMap stack = await isolate.getStack();
expect(stack.type, equals('Stack'));
expect(stack['frames'].length, greaterThanOrEqualTo(1));
Script script = stack['frames'][0].location.script;
expect(script.tokenToLine(stack['frames'][0].location.tokenPos),
equals(LINE_C));
},
resumeIsolate,
];
main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);