From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- js/src/tests/non262/template-strings/lineNumber.js | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 js/src/tests/non262/template-strings/lineNumber.js (limited to 'js/src/tests/non262/template-strings/lineNumber.js') diff --git a/js/src/tests/non262/template-strings/lineNumber.js b/js/src/tests/non262/template-strings/lineNumber.js new file mode 100644 index 0000000000..6163d5421d --- /dev/null +++ b/js/src/tests/non262/template-strings/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); -- cgit v1.2.3