michael@0: // Code runs fine if do-nothing breakpoints are set on every line. michael@0: michael@0: var g = newGlobal(); michael@0: var src = ("var line0 = Error().lineNumber;\n" + michael@0: "function gcd(a, b) {\n" + // line0 + 1 michael@0: " if (a > b)\n" + // line0 + 2 michael@0: " return gcd(b, a);\n" + // line0 + 3 michael@0: " var c = b % a;\n" + // line0 + 4 michael@0: " if (c === 0)\n" + // line0 + 5 michael@0: " return a;\n" + // line0 + 6 michael@0: " return gcd(c, a);\n" + // line0 + 7 michael@0: "}\n"); // line0 + 8 michael@0: g.eval(src); michael@0: michael@0: var dbg = Debugger(g); michael@0: var hits = 0 ; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: var s = frame.eval("gcd").return.script; michael@0: var offs; michael@0: for (var lineno = g.line0 + 2; (offs = s.getLineOffsets(lineno)).length > 0; lineno++) { michael@0: for (var i = 0; i < offs.length; i++) michael@0: s.setBreakpoint(offs[i], {hit: function (f) { hits++; }}); michael@0: } michael@0: assertEq(lineno > g.line0 + 7, true); michael@0: assertEq(lineno <= g.line0 + 9, true); michael@0: }; michael@0: michael@0: g.eval("debugger;"); michael@0: assertEq(g.gcd(31 * 7 * 5 * 3 * 2, 11 * 3 * 3 * 2), 6); michael@0: assertEq(hits >= 18, true);