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/inNotObjectError.js | |
parent | Initial commit. (diff) | |
download | firefox-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 '')
-rw-r--r-- | js/src/tests/non262/expressions/inNotObjectError.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/js/src/tests/non262/expressions/inNotObjectError.js b/js/src/tests/non262/expressions/inNotObjectError.js new file mode 100644 index 0000000000..3394ac0db7 --- /dev/null +++ b/js/src/tests/non262/expressions/inNotObjectError.js @@ -0,0 +1,46 @@ +var BUGNUMBER = 1352429; +var summary = 'Error message should provide enough infomation for use of in operator'; + +print(BUGNUMBER + ": " + summary); + +function checkErr(substr, str, messageSubstr, messageStr) { + var caught = false; + try { + substr in str; + } catch (e) { + caught = true; + assertEq(e.message.includes(messageSubstr), true); + assertEq(e.message.includes(messageStr), true); + assertEq(e.message.length < 100, true); + } + assertEq(caught, true); +} + +// These test cases check if long string is omitted properly. +checkErr('subString', 'base', 'subString', 'base'); +checkErr('this is subString', 'base', 'this is subStrin...', 'base'); +checkErr('subString', 'this is baseString', 'subString', 'this is baseStri...'); +checkErr('this is subString', 'this is base', 'this is subStrin...', 'this is base'); +checkErr('HEAD' + 'subString'.repeat(30000), 'HEAD' + 'base'.repeat(30000), 'HEADsubStringsub...', 'HEADbasebasebase...'); + +// These test cases check if it does not crash and throws appropriate error. +assertThrowsInstanceOf(() => { 1 in 'hello' }, TypeError); +assertThrowsInstanceOf(() => { 'hello' in 1 }, TypeError); +assertThrowsInstanceOf(() => { 'hello' in null }, TypeError); +assertThrowsInstanceOf(() => { null in 'hello' }, TypeError); +assertThrowsInstanceOf(() => { null in null }, TypeError); +assertThrowsInstanceOf(() => { 'hello' in true }, TypeError); +assertThrowsInstanceOf(() => { false in 1.1 }, TypeError); +assertThrowsInstanceOf(() => { Symbol.iterator in undefined }, TypeError); +assertThrowsInstanceOf(() => { [] in undefined }, TypeError); +assertThrowsInstanceOf(() => { /a/ in 'hello' }, TypeError); +var str = 'hello'; +assertThrowsInstanceOf(() => { str in 'hello' }, TypeError); +class A {}; +assertThrowsInstanceOf(() => { new A() in undefined }, TypeError); +var a = new A(); +a.b = 1.1; +assertThrowsInstanceOf(() => { a.b in 1.1 }, TypeError); + +if (typeof reportCompare === 'function') + reportCompare(0, 0); |