mirror of
https://github.com/tc39/test262.git
synced 2025-09-24 10:38:30 +02:00
Remove assertThrowsInstanceOfWithMessageCheck from tests
This commit is contained in:
parent
b5f946440f
commit
5f5d06f861
@ -4,25 +4,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js]
|
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
pending
|
||||||
esid: 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, ""]) {
|
for (var thisv of [null, undefined, false, true, 0, ""]) {
|
||||||
test(Map.prototype.values, thisv);
|
assert.throws(TypeError, () => Map.prototype.values.call(thisv));
|
||||||
test(Map.prototype.keys, thisv);
|
assert.throws(TypeError, () => Map.prototype.keys.call(thisv));
|
||||||
test(Map.prototype.entries, thisv);
|
assert.throws(TypeError, () => Map.prototype.entries.call(thisv));
|
||||||
test(Map.prototype[Symbol.iterator], thisv);
|
assert.throws(TypeError, () => Map.prototype[Symbol.iterator].call(thisv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,29 +9,16 @@ description: |
|
|||||||
pending
|
pending
|
||||||
esid: pending
|
esid: pending
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var BUGNUMBER = 1352429;
|
var BUGNUMBER = 1352429;
|
||||||
var summary = 'Error message should provide enough infomation for use of in operator';
|
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.
|
// These test cases check if long string is omitted properly.
|
||||||
checkErr('subString', 'base', 'subString', 'base');
|
assert.throws(TypeError, () => 'subString' in 'base');
|
||||||
checkErr('this is subString', 'base', 'this is subStrin...', 'base');
|
assert.throws(TypeError, () => 'this is subString' in 'base');
|
||||||
checkErr('subString', 'this is baseString', 'subString', 'this is baseStri...');
|
assert.throws(TypeError, () => 'subString' in 'this is baseString');
|
||||||
checkErr('this is subString', 'this is base', 'this is subStrin...', 'this is base');
|
assert.throws(TypeError, () => 'this is subString' in 'this is base');
|
||||||
checkErr('HEAD' + 'subString'.repeat(30000), 'HEAD' + 'base'.repeat(30000), 'HEADsubStringsub...', 'HEADbasebasebase...');
|
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.
|
// These test cases check if it does not crash and throws appropriate error.
|
||||||
assertThrowsInstanceOf(() => { 1 in 'hello' }, TypeError);
|
assertThrowsInstanceOf(() => { 1 in 'hello' }, TypeError);
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js]
|
includes: [sm/non262.js, sm/non262-shell.js]
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
pending
|
||||||
esid: pending
|
esid: pending
|
||||||
@ -24,27 +22,21 @@ esid: pending
|
|||||||
* proxies, it can be really hard to figure out what little assertion causes a
|
* proxies, it can be really hard to figure out what little assertion causes a
|
||||||
* TypeError in the first place.
|
* 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 STR = "one", STR_NAME = `"one"`;
|
||||||
const SYM = Symbol("two"), SYM_NAME = `'Symbol("two")'`;
|
const SYM = Symbol("two"), SYM_NAME = `'Symbol("two")'`;
|
||||||
|
|
||||||
function errorHasPropertyTests(test) {
|
function errorHasPropertyTests(test) {
|
||||||
assertThrowsTypeErrorIncludes(() => test(STR), STR_NAME);
|
assert.throws(TypeError, () => test(STR));
|
||||||
assertThrowsTypeErrorIncludes(() => test(SYM), SYM_NAME);
|
assert.throws(TypeError, () => test(SYM));
|
||||||
}
|
}
|
||||||
|
|
||||||
function errorHasPropertyTestsWithDetails(test) {
|
function errorHasPropertyTestsWithDetails(test) {
|
||||||
let [throwable, details] = test(STR);
|
let [throwable, details] = test(STR);
|
||||||
assertThrowsTypeErrorIncludes(throwable, STR_NAME, details);
|
assert.throws(TypeError, throwable, details);
|
||||||
|
|
||||||
[throwable, details] = test(SYM);
|
[throwable, details] = test(SYM);
|
||||||
assertThrowsTypeErrorIncludes(throwable, SYM_NAME, details);
|
assert.throws(TypeError, throwable, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
// getOwnPropertyDescriptor
|
// getOwnPropertyDescriptor
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js]
|
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
pending
|
||||||
esid: pending
|
esid: pending
|
||||||
@ -14,22 +11,8 @@ esid: pending
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
var BUGNUMBER = 469625;
|
var BUGNUMBER = 469625;
|
||||||
var summary = 'Do not assert: script->objectsOffset != 0';
|
var summary = 'Do not assert: script->objectsOffset != 0';
|
||||||
var actual = '';
|
|
||||||
var expect = '';
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
function f(x) {
|
||||||
test();
|
var [a, b, [c0, c1]] = [x, x, x];
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function test()
|
|
||||||
{
|
|
||||||
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));
|
||||||
|
@ -4,18 +4,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js]
|
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
pending
|
||||||
esid: pending
|
esid: pending
|
||||||
---*/
|
---*/
|
||||||
assertThrowsInstanceOfWithMessageCheck(
|
|
||||||
|
assert.throws(
|
||||||
|
TypeError,
|
||||||
() => {
|
() => {
|
||||||
{let i=1}
|
{let i=1}
|
||||||
{let j=1; [][j][2]}
|
{let j=1; [][j][2]}
|
||||||
},
|
}
|
||||||
TypeError,
|
);
|
||||||
message => message.endsWith("[][j] is undefined"));
|
|
||||||
|
|
||||||
|
@ -4,26 +4,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
includes: [sm/non262.js, sm/non262-shell.js]
|
|
||||||
flags:
|
|
||||||
- noStrict
|
|
||||||
description: |
|
description: |
|
||||||
pending
|
pending
|
||||||
esid: pending
|
esid: pending
|
||||||
---*/
|
---*/
|
||||||
var expect = '';
|
|
||||||
var actual = '';
|
|
||||||
|
|
||||||
function test(s) {
|
assert.throws(TypeError, () => eval("({p:1, q:2}).m()"));
|
||||||
assertThrowsInstanceOfWithMessageCheck(
|
assert.throws(TypeError, () => eval("[].m()"));
|
||||||
() => eval(s),
|
assert.throws(TypeError, () => eval("[1,2,3].m()"));
|
||||||
Error,
|
assert.throws(TypeError, () => eval("/hi/.m()"));
|
||||||
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()");
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user