mirror of
https://github.com/tc39/test262.git
synced 2025-09-24 10:38:30 +02:00
Remove assertThrowsInstanceOfWithMessage
This commit is contained in:
parent
5f5d06f861
commit
22bd116f5e
@ -5,7 +5,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*---
|
||||
defines: [assertThrowsValue, assertThrownErrorContains, assertThrowsInstanceOfWithMessageCheck, assertThrowsInstanceOf, assertThrowsInstanceOfWithMessage]
|
||||
defines: [assertThrowsValue, assertThrownErrorContains, assertThrowsInstanceOfWithMessageCheck, assertThrowsInstanceOf]
|
||||
allow_unused: True
|
||||
---*/
|
||||
|
||||
@ -70,11 +70,4 @@ allow_unused: True
|
||||
assertThrowsInstanceOfWithMessageCheck(f, ctor, _ => true, msg);
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof globalThis.assertThrowsInstanceOfWithMessage === 'undefined') {
|
||||
globalThis.assertThrowsInstanceOfWithMessage = function assertThrowsInstanceOfWithMessage(f, ctor, expected, msg) {
|
||||
assertThrowsInstanceOfWithMessageCheck(f, ctor, message => message === expected, msg);
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
@ -16,11 +16,14 @@ assertThrowsInstanceOf(() => eval(`class A { #x; #x; }`), SyntaxError);
|
||||
assertThrowsInstanceOf(
|
||||
() => eval(`var x = "foo"; class A { #[x] = 20; }`), SyntaxError);
|
||||
|
||||
assertThrowsInstanceOfWithMessage(() => eval(`class A { #x; h(o) { return !#x; }}`),
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval(`class A { #x; h(o) { return !#x; }}`),
|
||||
"invalid use of private name in unary expression without object reference");
|
||||
assertThrowsInstanceOfWithMessage(() => eval(`class A { #x; h(o) { return 1 + #x in o; }}`),
|
||||
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval(`class A { #x; h(o) { return 1 + #x in o; }}`),
|
||||
"invalid use of private name due to operator precedence");
|
||||
|
||||
|
||||
|
@ -9,13 +9,14 @@ description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
// Test that we can't confuse %StringIteratorPrototype% for a
|
||||
// StringIterator object.
|
||||
function TestStringIteratorPrototypeConfusion() {
|
||||
var iter = ""[Symbol.iterator]();
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
() => iter.next.call(Object.getPrototypeOf(iter)),
|
||||
assert.throws(
|
||||
TypeError,
|
||||
() => iter.next.call(Object.getPrototypeOf(iter)),
|
||||
"next method called on incompatible String Iterator");
|
||||
}
|
||||
TestStringIteratorPrototypeConfusion();
|
||||
|
@ -3,12 +3,11 @@
|
||||
|
||||
/*---
|
||||
includes: [sm/non262.js, sm/non262-shell.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
function testName(thisv) {
|
||||
var failures = [
|
||||
// Not a function
|
||||
@ -30,7 +29,7 @@ function testName(thisv) {
|
||||
assertThrowsInstanceOf(() => String.prototype[key].call(thisv), TypeError, key);
|
||||
} else {
|
||||
var expected = `String.prototype.${key} called on incompatible ${thisv}`;
|
||||
assertThrowsInstanceOfWithMessage(() => String.prototype[key].call(thisv), TypeError, expected, key)
|
||||
assert.throws(TypeError, () => String.prototype[key].call(thisv), expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -39,7 +38,7 @@ testName(undefined);
|
||||
|
||||
// On-off test for Symbol.iterator
|
||||
function testIterator(thisv) {
|
||||
assertThrowsInstanceOfWithMessage(() => String.prototype[Symbol.iterator].call(thisv), TypeError,
|
||||
assert.throws(TypeError, () => String.prototype[Symbol.iterator].call(thisv),
|
||||
`String.prototype[Symbol.iterator] called on incompatible ${thisv}`);
|
||||
}
|
||||
testIterator(null);
|
||||
|
@ -2,33 +2,27 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262.js, sm/non262-shell.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
function checkErr(f) {
|
||||
assertThrowsInstanceOfWithMessage(f, ReferenceError,
|
||||
"must call super constructor before using 'this' in derived class constructor");
|
||||
}
|
||||
|
||||
class TestNormal extends class {} {
|
||||
constructor() { this; }
|
||||
}
|
||||
checkErr(() => new TestNormal());
|
||||
assert.throws(ReferenceError, () => new TestNormal());
|
||||
|
||||
class TestEval extends class {} {
|
||||
constructor() { eval("this") }
|
||||
}
|
||||
checkErr(() => new TestEval());
|
||||
assert.throws(ReferenceError, () => new TestEval());
|
||||
|
||||
class TestNestedEval extends class {} {
|
||||
constructor() { eval("eval('this')") }
|
||||
}
|
||||
checkErr(() => new TestNestedEval());
|
||||
assert.throws(ReferenceError, () => new TestNestedEval());
|
||||
|
||||
checkErr(() => {
|
||||
assert.throws(ReferenceError, () => {
|
||||
new class extends class {} {
|
||||
constructor() { eval("this") }
|
||||
}
|
||||
@ -37,20 +31,19 @@ checkErr(() => {
|
||||
class TestArrow extends class {} {
|
||||
constructor() { (() => this)(); }
|
||||
}
|
||||
checkErr(() => new TestArrow());
|
||||
assert.throws(ReferenceError, () => new TestArrow());
|
||||
|
||||
class TestArrowEval extends class {} {
|
||||
constructor() { (() => eval("this"))(); }
|
||||
}
|
||||
checkErr(() => new TestArrowEval());
|
||||
assert.throws(ReferenceError, () => new TestArrowEval());
|
||||
|
||||
class TestEvalArrow extends class {} {
|
||||
constructor() { eval("(() => this)()"); }
|
||||
}
|
||||
checkErr(() => new TestEvalArrow());
|
||||
assert.throws(ReferenceError, () => new TestEvalArrow());
|
||||
|
||||
class TestTypeOf extends class {} {
|
||||
constructor() { eval("typeof this"); }
|
||||
}
|
||||
checkErr(() => new TestTypeOf());
|
||||
|
||||
assert.throws(ReferenceError, () => new TestTypeOf());
|
||||
|
@ -2,18 +2,16 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262.js, sm/non262-shell.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
for (let name of ["test", Symbol.match, Symbol.replace, Symbol.search]) {
|
||||
let methodName = typeof name === "symbol" ? `[${name.description}]` : name;
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
() => RegExp.prototype[name].call({}),
|
||||
assert.throws(
|
||||
TypeError,
|
||||
() => RegExp.prototype[name].call({}),
|
||||
`${methodName} method called on incompatible Object`);
|
||||
}
|
||||
|
||||
|
@ -2,31 +2,21 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262.js, sm/non262-shell.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
// The decompiler can handle the implicit call to @@iterator in a for-of loop.
|
||||
|
||||
var x;
|
||||
function check(code, msg) {
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
() => eval(code),
|
||||
TypeError,
|
||||
msg);
|
||||
}
|
||||
|
||||
x = {};
|
||||
check("for (var v of x) throw fit;", "x is not iterable");
|
||||
check("[...x]", "x is not iterable");
|
||||
check("Math.hypot(...x)", "x is not iterable");
|
||||
var x = {};
|
||||
assert.throws(TypeError, () => eval("for (var v of x) throw fit;"), "x is not iterable");
|
||||
assert.throws(TypeError, () => eval("[...x]"), "x is not iterable");
|
||||
assert.throws(TypeError, () => eval("Math.hypot(...x)"), "x is not iterable");
|
||||
|
||||
x[Symbol.iterator] = "potato";
|
||||
check("for (var v of x) throw fit;", "x is not iterable");
|
||||
assert.throws(TypeError, () => eval("for (var v of x) throw fit;"), "x is not iterable");
|
||||
|
||||
x[Symbol.iterator] = {};
|
||||
check("for (var v of x) throw fit;", "x[Symbol.iterator] is not a function");
|
||||
assert.throws(TypeError, () => eval("for (var v of x) throw fit;"), "x[Symbol.iterator] is not a function");
|
||||
|
||||
|
@ -2,30 +2,26 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262.js, sm/non262-shell.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var BUGNUMBER = 1384299;
|
||||
var summary = "yield outside of generators should provide better error";
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
() => eval("yield 10"),
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval("yield 10"),
|
||||
"yield expression is only valid in generators");
|
||||
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
() => eval("yield 10"),
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval("yield 10"),
|
||||
"yield expression is only valid in generators");
|
||||
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
() => eval("yield 10"),
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval("yield 10"),
|
||||
"yield expression is only valid in generators");
|
||||
|
||||
|
@ -4,20 +4,18 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [sm/non262.js, sm/non262-shell.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
var a = [];
|
||||
|
||||
// Test up to 200 to cover tunables such as js::PropertyTree::MAX_HEIGHT.
|
||||
for (var i = 0; i < 200; i++) {
|
||||
a.push("b" + i);
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
() => eval("(function ([" + a.join("],[") + "],a,a){})"),
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval("(function ([" + a.join("],[") + "],a,a){})"),
|
||||
'duplicate argument names not allowed in this context');
|
||||
}
|
||||
|
@ -4,13 +4,11 @@
|
||||
*/
|
||||
|
||||
/*---
|
||||
includes: [sm/non262.js, sm/non262-strict-shell.js, sm/non262-shell.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
|
||||
/**
|
||||
* These test cases check implementation-specific error messages for invalid
|
||||
* octal literals, octal escape sequences, and non-octal decimal escape
|
||||
@ -22,9 +20,9 @@ var JSMSG_DEPRECATED_OCTAL_ESCAPE = "octal escape sequences can't be used in unt
|
||||
var JSMSG_DEPRECATED_EIGHT_OR_NINE_ESCAPE = "the escapes \\8 and \\9 can't be used in untagged template literals or in strict mode code";
|
||||
|
||||
function checkPrologue(val, msg) {
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
() => eval('function invalid () { "' + val + '"; "use strict"; }'),
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval('function invalid () { "' + val + '"; "use strict"; }'),
|
||||
msg
|
||||
);
|
||||
}
|
||||
@ -34,9 +32,9 @@ checkPrologue('\\222', JSMSG_DEPRECATED_OCTAL_ESCAPE);
|
||||
checkPrologue('\\222\\8', JSMSG_DEPRECATED_EIGHT_OR_NINE_ESCAPE);
|
||||
|
||||
function checkAfter(val, msg) {
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
() => eval('function invalid () { "use strict" \n ' + val + ' }'),
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval('function invalid () { "use strict" \n ' + val + ' }'),
|
||||
msg
|
||||
);
|
||||
}
|
||||
|
@ -2,30 +2,28 @@
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
includes: [sm/non262.js, sm/non262-shell.js]
|
||||
flags:
|
||||
- noStrict
|
||||
description: |
|
||||
pending
|
||||
esid: pending
|
||||
---*/
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval("for (let case of ['foo', 'bar']) {}"),
|
||||
SyntaxError,
|
||||
"unexpected token: keyword 'case'");
|
||||
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval("for (let debugger of ['foo', 'bar']) {}"),
|
||||
SyntaxError,
|
||||
"unexpected token: keyword 'debugger'");
|
||||
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
() => eval("for (let case in ['foo', 'bar']) {}"),
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval("for (let case in ['foo', 'bar']) {}"),
|
||||
"unexpected token: keyword 'case'");
|
||||
|
||||
assertThrowsInstanceOfWithMessage(
|
||||
() => eval("for (let debugger in ['foo', 'bar']) {}"),
|
||||
assert.throws(
|
||||
SyntaxError,
|
||||
() => eval("for (let debugger in ['foo', 'bar']) {}"),
|
||||
"unexpected token: keyword 'debugger'");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user