From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../unterminated-literal-error-location.js | 120 +++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 js/src/tests/non262/extensions/unterminated-literal-error-location.js (limited to 'js/src/tests/non262/extensions/unterminated-literal-error-location.js') diff --git a/js/src/tests/non262/extensions/unterminated-literal-error-location.js b/js/src/tests/non262/extensions/unterminated-literal-error-location.js new file mode 100644 index 0000000000..999775ad10 --- /dev/null +++ b/js/src/tests/non262/extensions/unterminated-literal-error-location.js @@ -0,0 +1,120 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var BUGNUMBER = 1434429; +var summary = + "Report unterminated string/template literal errors with the line/column " + + "number of the point of non-termination"; + +function test(f, quotes, [line, col]) +{ + var caught = false; + try + { + f(); + } + catch (e) + { + caught = true; + assertEq(e.lineNumber, line, "line number"); + assertEq(e.columnNumber, col, "column number"); + assertEq(e.message.includes(quotes), true, + "message must contain delimiter"); + } + + assertEq(caught, true); +} + +test(function() { + //1234 + eval("'hi"); +}, "''", [1, 4]); + +test(function() { + //1234 5 + eval("'hi\\"); +}, "''", [1, 5]); + +test(function() { + //1234567 + eval(" 'hi"); +}, "''", [1, 7]); + +test(function() { + //1234567 8 + eval(" 'hi\\"); +}, "''", [1, 8]); + +test(function() { + //12345678 12345678 + eval('var x =\n "hi'); +}, '""', [2, 8]); + +test(function() { + //1234567 12345678 9 + eval('var x =\n "hi\\'); +}, '""', [2, 9]); + +test(function() { + // 1 + //1234567 12345678 123456789 12345678901234 + eval('var x =\n "hi\\\n bye\\\n no really'); +}, '""', [4, 14]); + +test(function() { + // 1 + //1234567 12345678 123456789 12345678901234 5 + eval('var x =\n "hi\\\n bye\\\n no really\\'); +}, '""', [4, 15]); + +test(function() { + //1234567 12345678 123456789 + eval('var x =\n "hi\\\n bye\n'); +}, '""', [3, 9]); + +test(function() { + // 1 + //1234567 12345678 123456789 0 + eval('var x =\n "hi\\\n bye\\'); +}, '""', [3, 10]); + +test(function() { + //1234567 12345678 + eval('var x =\n `'); +}, '``', [2, 8]); + +test(function() { + //1234567 12345678 9 + eval('var x =\n `\\'); +}, '``', [2, 9]); + +test(function() { + // 1 + //1234567 1234567890123456 + eval('var x =\n htmlEscape`'); +}, '``', [2, 16]); + +test(function() { + // 1 + //1234567 1234567890123456 7 + eval('var x =\n htmlEscape`\\'); +}, '``', [2, 17]); + +test(function() { + // 1 + //1234567 12345678901234 12345 + eval('var x =\n htmlEscape\n `'); +}, '``', [3, 5]); + +test(function() { + // 1 + //1234567 12345678901234 12345 6 + eval('var x =\n htmlEscape\n `\\'); +}, '``', [3, 6]); + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); + +print("Tests complete"); -- cgit v1.2.3