summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/parser/lineNumber.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/parser/lineNumber.js')
-rw-r--r--js/src/jit-test/tests/parser/lineNumber.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/parser/lineNumber.js b/js/src/jit-test/tests/parser/lineNumber.js
new file mode 100644
index 0000000000..f86efbc03e
--- /dev/null
+++ b/js/src/jit-test/tests/parser/lineNumber.js
@@ -0,0 +1,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);
+}