PageRenderTime 27ms CodeModel.GetById 13ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/jit-test/tests/debug/breakpoint-multi-01.js

http://github.com/zpao/v8monkey
JavaScript | 28 lines | 25 code | 2 blank | 1 comment | 2 complexity | 9886a43e747b42975f18b02836933e57 MD5 | raw file
 1// A single Debugger object can set multiple breakpoints at an instruction.
 2
 3var g = newGlobal('new-compartment');
 4var dbg = Debugger(g);
 5var log = '';
 6dbg.onDebuggerStatement = function (frame) {
 7    log += 'D';
 8    function handler(i) {
 9        return {hit: function (frame) { log += '' + i; }};
10    }
11    var f = frame.eval("f").return;
12    var s = f.script;
13    var offs = s.getLineOffsets(g.line0 + 2);
14    for (var i = 0; i < 10; i++) {
15        var bp = handler(i);
16        for (var j = 0; j < offs.length; j++)
17            s.setBreakpoint(offs[j], bp);
18    }
19    assertEq(f.call().return, 42);
20    log += 'X';
21};
22
23g.eval("var line0 = Error().lineNumber;\n" +
24       "function f() {\n" +  // line0 + 1
25       "    return 42;\n" +  // line0 + 2
26       "}\n" +
27       "debugger;\n");
28assertEq(log, 'D0123456789X');