summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/TemplateStrings/lineNumber.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_6/TemplateStrings/lineNumber.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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/tests/ecma_6/TemplateStrings/lineNumber.js')
-rw-r--r--js/src/tests/ecma_6/TemplateStrings/lineNumber.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/TemplateStrings/lineNumber.js b/js/src/tests/ecma_6/TemplateStrings/lineNumber.js
new file mode 100644
index 000000000..6163d5421
--- /dev/null
+++ b/js/src/tests/ecma_6/TemplateStrings/lineNumber.js
@@ -0,0 +1,72 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/licenses/publicdomain/ */
+
+var BUGNUMBER = 1253847;
+var summary = 'Line numbers should be updated correctly when a template literal contains CRLF sequences.';
+
+print(BUGNUMBER + ": " + summary);
+
+// lineNumber after template literal.
+var base, x, lineno;
+eval([
+ "base = new Error().lineNumber;",
+ "x = `",
+ "`;",
+ "lineno = new Error().lineNumber;",
+].join("\r\n"));
+assertEq(lineno, base + 3);
+
+eval([
+ "base = new Error().lineNumber;",
+ "x = `",
+ "",
+ "`;",
+ "lineno = new Error().lineNumber;",
+].join("\r\n"));
+assertEq(lineno, base + 4);
+
+eval([
+ "base = new Error().lineNumber;",
+ "x = `a",
+ "b`;",
+ "lineno = new Error().lineNumber;",
+].join("\r\n"));
+assertEq(lineno, base + 3);
+
+// lineNumber inside template literal
+eval([
+ "base = new Error().lineNumber;",
+ "x = `${new Error().lineNumber}",
+ "${new Error().lineNumber}",
+ "${new Error().lineNumber}`;",
+ "lineno = new Error().lineNumber;",
+].join("\r\n"));
+assertEq(lineno, base + 4);
+assertEq(x, (base + 1) + '\n' + (base + 2) + '\n' + (base + 3));
+
+eval([
+ "var base = new Error().lineNumber;",
+ "var x = `",
+ "${new Error().lineNumber}",
+ "${new Error().lineNumber}",
+ "${new Error().lineNumber}",
+ "`;",
+ "var lineno = new Error().lineNumber;",
+].join("\r\n"));
+assertEq(lineno, base + 6);
+assertEq(x, '\n' + (base + 2) + '\n' + (base + 3) + '\n' + (base + 4) + '\n');
+
+// When CR, LF, and CRLF are mixed.
+eval([
+ "var base = new Error().lineNumber;", "\n",
+ "var x = `${new Error().lineNumber}", "\n",
+ "${new Error().lineNumber}", "\r\n",
+ "${new Error().lineNumber}", "\r",
+ "${new Error().lineNumber}`;", "\n",
+ "var lineno = new Error().lineNumber;",
+].join(""));
+assertEq(lineno, base + 5);
+assertEq(x, (base + 1) + '\n' + (base + 2) + '\n' + (base + 3) + '\n' + (base + 4));
+
+if (typeof reportCompare === "function")
+ reportCompare(true, true);