diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/expressions/string-literal-escape-sequences.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.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/expressions/string-literal-escape-sequences.js')
-rw-r--r-- | js/src/tests/non262/expressions/string-literal-escape-sequences.js | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/js/src/tests/non262/expressions/string-literal-escape-sequences.js b/js/src/tests/non262/expressions/string-literal-escape-sequences.js new file mode 100644 index 0000000000..bc50b2c855 --- /dev/null +++ b/js/src/tests/non262/expressions/string-literal-escape-sequences.js @@ -0,0 +1,146 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 663300; +var summary = + "\\u and \\x must be followed by the appropriate number of hex digits or " + + "else it is a syntax error"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +function expectSyntaxError(str) +{ + try + { + eval(str); + } + catch (e) + { + assertEq(e instanceof SyntaxError, true, + "no syntax error evaluating " + str); + } +} + +expectSyntaxError('"\\x"'); +expectSyntaxError('"\\x0"'); +expectSyntaxError('"\\x1"'); +expectSyntaxError('"\\x2"'); +expectSyntaxError('"\\x3"'); +expectSyntaxError('"\\x4"'); +expectSyntaxError('"\\x5"'); +expectSyntaxError('"\\x6"'); +expectSyntaxError('"\\x7"'); +expectSyntaxError('"\\x8"'); +expectSyntaxError('"\\x9"'); +expectSyntaxError('"\\xA"'); +expectSyntaxError('"\\xB"'); +expectSyntaxError('"\\xC"'); +expectSyntaxError('"\\xD"'); +expectSyntaxError('"\\xE"'); +expectSyntaxError('"\\xF"'); +expectSyntaxError('"\\xG"'); +expectSyntaxError('"\\x0G"'); +expectSyntaxError('"\\x1G"'); +expectSyntaxError('"\\x2G"'); +expectSyntaxError('"\\x3G"'); +expectSyntaxError('"\\x4G"'); +expectSyntaxError('"\\x5G"'); +expectSyntaxError('"\\x6G"'); +expectSyntaxError('"\\x7G"'); +expectSyntaxError('"\\x8G"'); +expectSyntaxError('"\\x9G"'); +expectSyntaxError('"\\xAG"'); +expectSyntaxError('"\\xBG"'); +expectSyntaxError('"\\xCG"'); +expectSyntaxError('"\\xDG"'); +expectSyntaxError('"\\xEG"'); +expectSyntaxError('"\\xFG"'); +expectSyntaxError('"\\xGG"'); + +expectSyntaxError('"\\u"'); +expectSyntaxError('"\\u0"'); +expectSyntaxError('"\\u1"'); +expectSyntaxError('"\\u2"'); +expectSyntaxError('"\\u3"'); +expectSyntaxError('"\\u4"'); +expectSyntaxError('"\\u5"'); +expectSyntaxError('"\\u6"'); +expectSyntaxError('"\\u7"'); +expectSyntaxError('"\\u8"'); +expectSyntaxError('"\\u9"'); +expectSyntaxError('"\\uA"'); +expectSyntaxError('"\\uB"'); +expectSyntaxError('"\\uC"'); +expectSyntaxError('"\\uD"'); +expectSyntaxError('"\\uE"'); +expectSyntaxError('"\\uF"'); +expectSyntaxError('"\\uG"'); +expectSyntaxError('"\\u00"'); +expectSyntaxError('"\\u11"'); +expectSyntaxError('"\\u22"'); +expectSyntaxError('"\\u33"'); +expectSyntaxError('"\\u44"'); +expectSyntaxError('"\\u55"'); +expectSyntaxError('"\\u66"'); +expectSyntaxError('"\\u77"'); +expectSyntaxError('"\\u88"'); +expectSyntaxError('"\\u99"'); +expectSyntaxError('"\\uAA"'); +expectSyntaxError('"\\uBB"'); +expectSyntaxError('"\\uCC"'); +expectSyntaxError('"\\uDD"'); +expectSyntaxError('"\\uEE"'); +expectSyntaxError('"\\uFF"'); +expectSyntaxError('"\\uGG"'); +expectSyntaxError('"\\u000"'); +expectSyntaxError('"\\u111"'); +expectSyntaxError('"\\u222"'); +expectSyntaxError('"\\u333"'); +expectSyntaxError('"\\u444"'); +expectSyntaxError('"\\u555"'); +expectSyntaxError('"\\u666"'); +expectSyntaxError('"\\u777"'); +expectSyntaxError('"\\u888"'); +expectSyntaxError('"\\u999"'); +expectSyntaxError('"\\uAAA"'); +expectSyntaxError('"\\uBBB"'); +expectSyntaxError('"\\uCCC"'); +expectSyntaxError('"\\uDDD"'); +expectSyntaxError('"\\uEEE"'); +expectSyntaxError('"\\uFFF"'); +expectSyntaxError('"\\uGGG"'); +expectSyntaxError('"\\u000G"'); +expectSyntaxError('"\\u111G"'); +expectSyntaxError('"\\u222G"'); +expectSyntaxError('"\\u333G"'); +expectSyntaxError('"\\u444G"'); +expectSyntaxError('"\\u555G"'); +expectSyntaxError('"\\u666G"'); +expectSyntaxError('"\\u777G"'); +expectSyntaxError('"\\u888G"'); +expectSyntaxError('"\\u999G"'); +expectSyntaxError('"\\uAAAG"'); +expectSyntaxError('"\\uBBBG"'); +expectSyntaxError('"\\uCCCG"'); +expectSyntaxError('"\\uDDDG"'); +expectSyntaxError('"\\uEEEG"'); +expectSyntaxError('"\\uFFFG"'); +expectSyntaxError('"\\uGGGG"'); + +assertEq(eval('"a\\\rb"'), "ab"); +assertEq(eval('"a\\\nb"'), "ab"); +assertEq(eval('"a\\\r\nb"'), "ab"); +assertEq(eval('"a\\\u2028b"'), "ab"); +assertEq(eval('"a\\\u2029b"'), "ab"); + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); |