diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/debug/Script-getLineOffsets-06.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/debug/Script-getLineOffsets-06.js')
-rw-r--r-- | js/src/jit-test/tests/debug/Script-getLineOffsets-06.js | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Script-getLineOffsets-06.js b/js/src/jit-test/tests/debug/Script-getLineOffsets-06.js new file mode 100644 index 000000000..da312ccf9 --- /dev/null +++ b/js/src/jit-test/tests/debug/Script-getLineOffsets-06.js @@ -0,0 +1,99 @@ +// getLineOffsets works with extended instructions, such as JSOP_GOTOX. + +var g = newGlobal(); +g.line0 = null; +var dbg = Debugger(g); +var where; +dbg.onDebuggerStatement = function (frame) { + var s = frame.script; + var offs; + var lineno = g.line0 + where; + offs = s.getLineOffsets(lineno); + for (var i = 0; i < offs.length; i++) { + assertEq(s.getOffsetLocation(offs[i]).lineNumber, lineno); + s.setBreakpoint(offs[i], {hit: function (frame) { g.log += 'B'; }}); + } + g.log += 'A'; +}; + +function test(s) { + assertEq(s.charAt(s.length - 1) !== '\n', true); + var count = s.split(/\n/).length; // number of lines in s + g.i = 0; + g.log = ''; + where = 1 + count; + g.eval("line0 = Error().lineNumber;\n" + + "debugger;\n" + // line0 + 1 + s + // line0 + 2 ... line0 + where + " log += 'C';\n"); + assertEq(g.log, 'ABC'); +} + +function repeat(s) { + return Array((1 << 14) + 1).join(s); // 16K copies of s +} +var long_expr = "i" + repeat(" + i"); +var long_throw_stmt = "throw " + long_expr + ";\n"; + +// long break (JSOP_GOTOX) +test("for (;;) {\n" + + " if (i === 0)\n" + + " break;\n" + + " " + long_throw_stmt + + "}"); + +// long continue (JSOP_GOTOX) +test("do {\n" + + " if (i === 0)\n" + + " continue;\n" + + " " + long_throw_stmt + + "} while (i !== 0);"); + +// long if consequent (JSOP_IFEQX) +test("if (i === 2) {\n" + + " " + long_throw_stmt + + "}"); + +// long catch-block with finally (JSOP_GOSUBX) +test("try {\n" + + " i = 0;\n" + + "} catch (exc) {\n" + + " throw " + long_expr + ";\n" + + "} finally {\n" + + " i = 1;\n" + + "}"); + +// long case (JSOP_TABLESWITCHX) +test("switch (i) {\n" + + " default:\n" + + " case 1: " + long_throw_stmt + + " case 0: i++; }"); + +test("switch (i) {\n" + + " case 1: case 2: case 3: " + long_throw_stmt + + " default: i++; }"); + +// long case (JSOP_LOOKUPSWITCHX) +test("switch ('' + i) {\n" + + " default:\n" + + " case '1': " + long_throw_stmt + + " case '0': i++; }"); + +test("switch (i) {\n" + + " case '1': case '2': case '3': " + long_throw_stmt + + " default: i++; }"); + +// long case or case-expression (JSOP_CASEX) +test("switch (i) {\n" + + " case i + 1 - i:\n" + + " default:\n" + + " " + long_throw_stmt + + " case i + i:\n" + + " i++; break; }"); + +// long case when JSOP_CASE is used (JSOP_DEFAULTX) +test("switch (i) {\n" + + " case i + 1 - i:\n" + + " " + long_throw_stmt + + " default:\n" + + " i++; break; }"); |