summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/parser/lineNumber.js
blob: f86efbc03e67d6d84f06972b4b10fe32da497383 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Simple tests for evaluate's "lineNumber" option.

load(libdir + 'asserts.js');

const maxLine = Math.pow(2,32) - 1;

assertEq(evaluate("saveStack().line"), 1);
assertEq(evaluate("saveStack().line", { lineNumber: maxLine }), maxLine);
assertEq(evaluate("\nsaveStack().line"), 2);
assertEq(evaluate("\nsaveStack().line", { lineNumber: 1000 }), 1001);
assertThrowsInstanceOf(() => evaluate("\nsaveStack().line", { lineNumber: maxLine }),
                       RangeError);

if (helperThreadCount() > 0) {
  offThreadCompileToStencil("saveStack().line");
  var stencil = finishOffThreadStencil();
  assertEq(evalStencil(stencil), 1);

  offThreadCompileToStencil("saveStack().line", { lineNumber: maxLine });
  stencil = finishOffThreadStencil();
  assertEq(evalStencil(stencil), maxLine);

  offThreadCompileToStencil("\nsaveStack().line");
  stencil = finishOffThreadStencil();
  assertEq(evalStencil(stencil), 2);

  offThreadCompileToStencil("\nsaveStack().line", { lineNumber: 1000 });
  stencil = finishOffThreadStencil();
  assertEq(evalStencil(stencil), 1001);

  offThreadCompileToStencil("\nsaveStack().line", { lineNumber: maxLine });
  assertThrowsInstanceOf(() => {
    stencil = finishOffThreadStencil();
    evalStencil(stencil);
  }, RangeError);
}