diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /js/src/tests/non262/extensions/unterminated-literal-error-location.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/non262/extensions/unterminated-literal-error-location.js')
-rw-r--r-- | js/src/tests/non262/extensions/unterminated-literal-error-location.js | 119 |
1 files changed, 119 insertions, 0 deletions
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..de9767a1c2 --- /dev/null +++ b/js/src/tests/non262/extensions/unterminated-literal-error-location.js @@ -0,0 +1,119 @@ +/* + * 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() { + //0123 + eval("'hi"); +}, "''", [1, 3]); + +test(function() { + //0123 4 + eval("'hi\\"); +}, "''", [1, 4]); + +test(function() { + //0123456 + eval(" 'hi"); +}, "''", [1, 6]); + +test(function() { + //0123456 7 + eval(" 'hi\\"); +}, "''", [1, 7]); + +test(function() { + //01234567 01234567 + eval('var x =\n "hi'); +}, '""', [2, 7]); + +test(function() { + //0123456 01234567 8 + eval('var x =\n "hi\\'); +}, '""', [2, 8]); + +test(function() { + // 1 + //0123456 01234567 012345678 01234567890123 + eval('var x =\n "hi\\\n bye\\\n no really'); +}, '""', [4, 13]); + +test(function() { + // 1 + //0123456 01234567 012345678 01234567890123 4 + eval('var x =\n "hi\\\n bye\\\n no really\\'); +}, '""', [4, 14]); + +test(function() { + //0123456 01234567 012345678 + eval('var x =\n "hi\\\n bye\n'); +}, '""', [3, 8]); + +test(function() { + //0123456 01234567 012345678 9 + eval('var x =\n "hi\\\n bye\\'); +}, '""', [3, 9]); + +test(function() { + //0123456 01234567 + eval('var x =\n `'); +}, '``', [2, 7]); + +test(function() { + //0123456 01234567 8 + eval('var x =\n `\\'); +}, '``', [2, 8]); + +test(function() { + // 1 + //0123456 0123456789012345 + eval('var x =\n htmlEscape`'); +}, '``', [2, 15]); + +test(function() { + // 1 + //0123456 0123456789012345 6 + eval('var x =\n htmlEscape`\\'); +}, '``', [2, 16]); + +test(function() { + // 1 + //0123456 01234567890123 01234 + eval('var x =\n htmlEscape\n `'); +}, '``', [3, 4]); + +test(function() { + // 1 + //0123456 01234567890123 01234 5 + eval('var x =\n htmlEscape\n `\\'); +}, '``', [3, 5]); + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); + +print("Tests complete"); |