return-break-locations.js 928 Bytes
Newer Older
1 2 3 4
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
let {session, contextGroup, Protocol} = InspectorTest.start('Return break locations within function');
6

7
contextGroup.addScript(`
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
function fib(x) {
  if (x < 0) return;
  if (x === 0) return 1;
  if (x === 1) return fib(0);
  return x > 2 ? fib(x - 1) + fib(x - 2) : fib(1) + fib(0);
}
`);

InspectorTest.runAsyncTestSuite([
  async function testTailCall() {
    var scriptPromise = Protocol.Debugger.onceScriptParsed();
    Protocol.Debugger.enable();
    var scriptId = (await scriptPromise).params.scriptId;
    var locations = (await Protocol.Debugger.getPossibleBreakpoints({
      start: { lineNumber: 0, columnNumber: 0, scriptId }
    })).result.locations;
    InspectorTest.logMessage(locations.filter(location => location.type === 'return'));
  }
]);