Remove assertThrowsInstanceOfWithMessageCheck from tests

This commit is contained in:
André Bargull 2025-04-30 14:15:41 +02:00 committed by Philip Chimento
parent b5f946440f
commit 5f5d06f861
6 changed files with 26 additions and 89 deletions

View File

@ -4,25 +4,15 @@
*/
/*---
includes: [sm/non262.js, sm/non262-shell.js]
flags:
- noStrict
description: |
pending
esid: pending
---*/
function test(fn, thisv) {
assertThrowsInstanceOfWithMessageCheck(
() => fn.call(thisv),
TypeError,
message =>
/^\w+ method called on incompatible.+/.test(message) && !message.includes("std_"));
}
for (var thisv of [null, undefined, false, true, 0, ""]) {
test(Map.prototype.values, thisv);
test(Map.prototype.keys, thisv);
test(Map.prototype.entries, thisv);
test(Map.prototype[Symbol.iterator], thisv);
assert.throws(TypeError, () => Map.prototype.values.call(thisv));
assert.throws(TypeError, () => Map.prototype.keys.call(thisv));
assert.throws(TypeError, () => Map.prototype.entries.call(thisv));
assert.throws(TypeError, () => Map.prototype[Symbol.iterator].call(thisv));
}

View File

@ -9,29 +9,16 @@ description: |
pending
esid: pending
---*/
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) {
assertThrowsInstanceOfWithMessageCheck(
() => substr in str,
TypeError,
message =>
message.includes(messageSubstr) &&
message.includes(messageStr) &&
message.length < 100,
`"${substr}" in "${str}"`
);
}
// 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...');
assert.throws(TypeError, () => 'subString' in 'base');
assert.throws(TypeError, () => 'this is subString' in 'base');
assert.throws(TypeError, () => 'subString' in 'this is baseString');
assert.throws(TypeError, () => 'this is subString' in 'this is base');
assert.throws(TypeError, () => 'HEAD' + 'subString'.repeat(30000) in 'HEAD' + 'base'.repeat(30000));
// These test cases check if it does not crash and throws appropriate error.
assertThrowsInstanceOf(() => { 1 in 'hello' }, TypeError);

View File

@ -5,8 +5,6 @@
/*---
includes: [sm/non262.js, sm/non262-shell.js]
flags:
- noStrict
description: |
pending
esid: pending
@ -24,27 +22,21 @@ esid: pending
* proxies, it can be really hard to figure out what little assertion causes a
* TypeError in the first place.
*/
"use strict";
function assertThrowsTypeErrorIncludes(f, propStr, details) {
assertThrowsInstanceOfWithMessageCheck(f, TypeError,
message => message.includes(propStr) && (!details || message.includes(details)));
}
const STR = "one", STR_NAME = `"one"`;
const SYM = Symbol("two"), SYM_NAME = `'Symbol("two")'`;
function errorHasPropertyTests(test) {
assertThrowsTypeErrorIncludes(() => test(STR), STR_NAME);
assertThrowsTypeErrorIncludes(() => test(SYM), SYM_NAME);
assert.throws(TypeError, () => test(STR));
assert.throws(TypeError, () => test(SYM));
}
function errorHasPropertyTestsWithDetails(test) {
let [throwable, details] = test(STR);
assertThrowsTypeErrorIncludes(throwable, STR_NAME, details);
assert.throws(TypeError, throwable, details);
[throwable, details] = test(SYM);
assertThrowsTypeErrorIncludes(throwable, SYM_NAME, details);
assert.throws(TypeError, throwable, details);
}
// getOwnPropertyDescriptor

View File

@ -4,9 +4,6 @@
*/
/*---
includes: [sm/non262.js, sm/non262-shell.js]
flags:
- noStrict
description: |
pending
esid: pending
@ -14,22 +11,8 @@ esid: pending
//-----------------------------------------------------------------------------
var BUGNUMBER = 469625;
var summary = 'Do not assert: script->objectsOffset != 0';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
function f(x) {
function f(x) {
var [a, b, [c0, c1]] = [x, x, x];
}
assertThrowsInstanceOfWithMessageCheck(
() => f(null),
TypeError,
message => /.*\[\.\.\.\]\[Symbol.iterator\]\(\)\.next\(\)\.value is null/.exec(message) !== null
);
}
assert.throws(TypeError, () => f(null));

View File

@ -4,18 +4,16 @@
*/
/*---
includes: [sm/non262.js, sm/non262-shell.js]
flags:
- noStrict
description: |
pending
esid: pending
---*/
assertThrowsInstanceOfWithMessageCheck(
assert.throws(
TypeError,
() => {
{let i=1}
{let j=1; [][j][2]}
},
TypeError,
message => message.endsWith("[][j] is undefined"));
}
);

View File

@ -4,26 +4,13 @@
*/
/*---
includes: [sm/non262.js, sm/non262-shell.js]
flags:
- noStrict
description: |
pending
esid: pending
---*/
var expect = '';
var actual = '';
function test(s) {
assertThrowsInstanceOfWithMessageCheck(
() => eval(s),
Error,
message => message.indexOf('(intermediate value)') === -1,
`error message for ${s} should not contain '(intermediate value)'`);
}
test("({p:1, q:2}).m()");
test("[].m()");
test("[1,2,3].m()");
test("/hi/.m()");
assert.throws(TypeError, () => eval("({p:1, q:2}).m()"));
assert.throws(TypeError, () => eval("[].m()"));
assert.throws(TypeError, () => eval("[1,2,3].m()"));
assert.throws(TypeError, () => eval("/hi/.m()"));