michael@0: /* michael@0: * For arrow functions, Script.prototype.sourceStart and michael@0: * Script.prototype.sourceLength should comprise the entire function expression michael@0: * (including arguments) michael@0: */ michael@0: let g = newGlobal(); michael@0: let dbg = new Debugger(g); michael@0: michael@0: function test(string, ranges) { michael@0: var index = 0; michael@0: dbg.onNewScript = function (script) { michael@0: function traverse(script) { michael@0: script.getChildScripts().forEach(function (script) { michael@0: assertEq(script.sourceStart, ranges[index][0]); michael@0: assertEq(script.sourceLength, ranges[index][1]); michael@0: ++index; michael@0: traverse(script); michael@0: }); michael@0: } michael@0: traverse(script); michael@0: }; michael@0: michael@0: g.eval(string); michael@0: michael@0: /* michael@0: * In some configurations certain child scripts are listed twice, so we michael@0: * cannot rely on index always having the exact same value michael@0: */ michael@0: assertEq(0 < index && index <= ranges.length, true); michael@0: }; michael@0: michael@0: test("() => {}", [[0, 8]]); michael@0: test("(x, y) => { x * y }", [[0, 19]]); michael@0: test("x => x * x", [[0, 10]]); michael@0: test("x => x => x * x", [[0, 15], [5, 10], [5, 10]]);