summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/extensions/unterminated-literal-error-location.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/extensions/unterminated-literal-error-location.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
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.js119
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");