diff --git a/test/staging/sm/Function/Function-prototype.js b/test/staging/sm/Function/Function-prototype.js index c271610ce1..8f396fd9da 100644 --- a/test/staging/sm/Function/Function-prototype.js +++ b/test/staging/sm/Function/Function-prototype.js @@ -15,6 +15,6 @@ assert.deepEqual(desc, assert.sameValue(Function.prototype.prototype, undefined); assert.sameValue(Function.prototype.callee, undefined); -assertThrowsInstanceOf(() => Function.prototype.caller, TypeError); -assertThrowsInstanceOf(() => Function.prototype.arguments, TypeError); +assert.throws(TypeError, () => Function.prototype.caller); +assert.throws(TypeError, () => Function.prototype.arguments); diff --git a/test/staging/sm/Function/arrow-has-duplicated.js b/test/staging/sm/Function/arrow-has-duplicated.js index fb4709e333..0dd2d9a8ca 100644 --- a/test/staging/sm/Function/arrow-has-duplicated.js +++ b/test/staging/sm/Function/arrow-has-duplicated.js @@ -14,12 +14,12 @@ function f0(a, a) { } // SyntaxError should be thrown if arrow function has duplicated name. -assertThrowsInstanceOf(() => eval(` +assert.throws(SyntaxError, () => eval(` (a, a) => { }; -`), SyntaxError); -assertThrowsInstanceOf(() => eval(` +`)); +assert.throws(SyntaxError, () => eval(` (a, ...a) => { }; -`), SyntaxError); +`)); diff --git a/test/staging/sm/Function/bound-non-constructable.js b/test/staging/sm/Function/bound-non-constructable.js index 69de3f9d4e..c564a2fb87 100644 --- a/test/staging/sm/Function/bound-non-constructable.js +++ b/test/staging/sm/Function/bound-non-constructable.js @@ -22,6 +22,6 @@ for (var obj of objects) { // Make sure they are callable, but not constructable. obj(); - assertThrowsInstanceOf(() => new obj, TypeError); + assert.throws(TypeError, () => new obj); } diff --git a/test/staging/sm/Function/create-function-parse-before-getprototype.js b/test/staging/sm/Function/create-function-parse-before-getprototype.js index 7c5e9474d1..baeb55eb04 100644 --- a/test/staging/sm/Function/create-function-parse-before-getprototype.js +++ b/test/staging/sm/Function/create-function-parse-before-getprototype.js @@ -18,9 +18,9 @@ var newTarget = Object.defineProperty(function(){}.bind(), "prototype", { } }); -assertThrowsInstanceOf(() => { +assert.throws(SyntaxError, () => { Reflect.construct(Function, ["@error"], newTarget); -}, SyntaxError); +}); assert.sameValue(getProtoCalled, false); diff --git a/test/staging/sm/Function/function-bind.js b/test/staging/sm/Function/function-bind.js index d796ae515e..641a70b54d 100644 --- a/test/staging/sm/Function/function-bind.js +++ b/test/staging/sm/Function/function-bind.js @@ -47,27 +47,22 @@ assert.sameValue(strictReturnThis.bind("foopy")(), "foopy"); // rigorous, step-by-step testing -function expectThrowTypeError(fun) -{ - assertThrowsInstanceOf(fun, TypeError); -} - /* * 1. Let Target be the this value. * 2. If IsCallable(Target) is false, throw a TypeError exception. */ -expectThrowTypeError(function() { bind.call(null); }); -expectThrowTypeError(function() { bind.call(undefined); }); -expectThrowTypeError(function() { bind.call(NaN); }); -expectThrowTypeError(function() { bind.call(0); }); -expectThrowTypeError(function() { bind.call(-0); }); -expectThrowTypeError(function() { bind.call(17); }); -expectThrowTypeError(function() { bind.call(42); }); -expectThrowTypeError(function() { bind.call("foobar"); }); -expectThrowTypeError(function() { bind.call(true); }); -expectThrowTypeError(function() { bind.call(false); }); -expectThrowTypeError(function() { bind.call([]); }); -expectThrowTypeError(function() { bind.call({}); }); +assert.throws(TypeError, function() { bind.call(null); }); +assert.throws(TypeError, function() { bind.call(undefined); }); +assert.throws(TypeError, function() { bind.call(NaN); }); +assert.throws(TypeError, function() { bind.call(0); }); +assert.throws(TypeError, function() { bind.call(-0); }); +assert.throws(TypeError, function() { bind.call(17); }); +assert.throws(TypeError, function() { bind.call(42); }); +assert.throws(TypeError, function() { bind.call("foobar"); }); +assert.throws(TypeError, function() { bind.call(true); }); +assert.throws(TypeError, function() { bind.call(false); }); +assert.throws(TypeError, function() { bind.call([]); }); +assert.throws(TypeError, function() { bind.call({}); }); /* @@ -254,8 +249,8 @@ function testBound(fun) assert.sameValue(Object.getOwnPropertyDescriptor(boundf, "caller"), undefined, "should be no caller property"); - expectThrowTypeError(function() { return boundf.arguments; }); - expectThrowTypeError(function() { return boundf.caller; }); + assert.throws(TypeError, function() { return boundf.arguments; }); + assert.throws(TypeError, function() { return boundf.caller; }); } testBound(strict); diff --git a/test/staging/sm/Function/has-instance.js b/test/staging/sm/Function/has-instance.js index ed6f99d086..9474f6654f 100644 --- a/test/staging/sm/Function/has-instance.js +++ b/test/staging/sm/Function/has-instance.js @@ -53,11 +53,11 @@ for (let nonCallable of nonCallables) { // Non-callables should throw when used on the right hand side // of `instanceof`. -assertThrowsInstanceOf(() => { +assert.throws(TypeError, () => { function foo() {}; let obj = {}; foo instanceof obj; -}, TypeError); +}); // Non-callables do not throw for overridden methods let o = {[Symbol.hasInstance](v) { return true; }} @@ -97,7 +97,7 @@ assert.sameValue(desc.configurable, false); // Attempting to use a non-callable @@hasInstance triggers a type error // Bug 1280892 -assertThrowsInstanceOf(() => { +assert.throws(TypeError, () => { var fun = function() {} var p = new Proxy(fun, { get(target, key) { @@ -105,6 +105,6 @@ assertThrowsInstanceOf(() => { } }); fun instanceof p; -}, TypeError); +}); diff --git a/test/staging/sm/Function/invalid-parameter-list.js b/test/staging/sm/Function/invalid-parameter-list.js index 31daa5edfb..cfff53533e 100644 --- a/test/staging/sm/Function/invalid-parameter-list.js +++ b/test/staging/sm/Function/invalid-parameter-list.js @@ -32,6 +32,6 @@ const tests = [ for (const test of tests) { DumpFunction(...test); - assertThrowsInstanceOf(() => new Function(...test), SyntaxError); + assert.throws(SyntaxError, () => new Function(...test)); } diff --git a/test/staging/sm/Function/line-terminator-before-arrow.js b/test/staging/sm/Function/line-terminator-before-arrow.js index a6138fae3e..c3c430d604 100644 --- a/test/staging/sm/Function/line-terminator-before-arrow.js +++ b/test/staging/sm/Function/line-terminator-before-arrow.js @@ -9,11 +9,11 @@ description: | pending esid: pending ---*/ -assertThrowsInstanceOf(() => eval("() \n => {}"), SyntaxError); -assertThrowsInstanceOf(() => eval("a \n => {}"), SyntaxError); -assertThrowsInstanceOf(() => eval("(a) /*\n*/ => {}"), SyntaxError); -assertThrowsInstanceOf(() => eval("(a, b) \n => {}"), SyntaxError); -assertThrowsInstanceOf(() => eval("(a, b = 1) \n => {}"), SyntaxError); -assertThrowsInstanceOf(() => eval("(a, ...b) \n => {}"), SyntaxError); -assertThrowsInstanceOf(() => eval("(a, b = 1, ...c) \n => {}"), SyntaxError); +assert.throws(SyntaxError, () => eval("() \n => {}")); +assert.throws(SyntaxError, () => eval("a \n => {}")); +assert.throws(SyntaxError, () => eval("(a) /*\n*/ => {}")); +assert.throws(SyntaxError, () => eval("(a, b) \n => {}")); +assert.throws(SyntaxError, () => eval("(a, b = 1) \n => {}")); +assert.throws(SyntaxError, () => eval("(a, ...b) \n => {}")); +assert.throws(SyntaxError, () => eval("(a, b = 1, ...c) \n => {}")); diff --git a/test/staging/sm/Function/method-has-duplicated.js b/test/staging/sm/Function/method-has-duplicated.js index 18c4e3e2fd..ef98eb2e42 100644 --- a/test/staging/sm/Function/method-has-duplicated.js +++ b/test/staging/sm/Function/method-has-duplicated.js @@ -14,16 +14,16 @@ function f0(a) { } // SyntaxError should be thrown if method definition has duplicated name. -assertThrowsInstanceOf(() => eval(` +assert.throws(SyntaxError, () => eval(` ({ m1(a, a) { } }); -`), SyntaxError); -assertThrowsInstanceOf(() => eval(` +`)); +assert.throws(SyntaxError, () => eval(` ({ m2(a, ...a) { } }); -`), SyntaxError); +`)); diff --git a/test/staging/sm/Function/parameter-redeclaration.js b/test/staging/sm/Function/parameter-redeclaration.js index 0df674a567..75f3d117e4 100644 --- a/test/staging/sm/Function/parameter-redeclaration.js +++ b/test/staging/sm/Function/parameter-redeclaration.js @@ -15,14 +15,14 @@ function f1(a = 0) { } // 'let' and 'const' at body-level are not allowed to redeclare parameters. -assertThrowsInstanceOf(() => { +assert.throws(SyntaxError, () => { eval(`function f2(a = 0) { let a; }`); -}, SyntaxError); -assertThrowsInstanceOf(() => { +}); +assert.throws(SyntaxError, () => { eval(`function f3(a = 0) { const a; }`); -}, SyntaxError); +}); diff --git a/test/staging/sm/Function/rest-has-duplicated.js b/test/staging/sm/Function/rest-has-duplicated.js index d50bc48d99..06f901975e 100644 --- a/test/staging/sm/Function/rest-has-duplicated.js +++ b/test/staging/sm/Function/rest-has-duplicated.js @@ -14,14 +14,14 @@ function f0(a, a) { } // SyntaxError should be thrown if rest parameter name is duplicated. -assertThrowsInstanceOf(() => eval(` +assert.throws(SyntaxError, () => eval(` function f1(a, ...a) { } -`), SyntaxError); +`)); // SyntaxError should be thrown if there is a duplicated parameter. -assertThrowsInstanceOf(() => eval(` +assert.throws(SyntaxError, () => eval(` function f2(a, a, ...b) { } -`), SyntaxError); +`)); diff --git a/test/staging/sm/Function/rest-parameter-names.js b/test/staging/sm/Function/rest-parameter-names.js index 64a35055cf..beda8871e7 100644 --- a/test/staging/sm/Function/rest-parameter-names.js +++ b/test/staging/sm/Function/rest-parameter-names.js @@ -61,11 +61,9 @@ function h() for (var badName of ["yield", "eval", "let"]) { - assertThrowsInstanceOf(() => eval(`var q = (...${badName}) => ${badName} + 42;`), - SyntaxError); + assert.throws(SyntaxError, () => eval(`var q = (...${badName}) => ${badName} + 42;`)); - assertThrowsInstanceOf(() => eval(`function r(x, ...${badName}) { return x + ${badName}; }`), - SyntaxError); + assert.throws(SyntaxError, () => eval(`function r(x, ...${badName}) { return x + ${badName}; }`)); } } h(); diff --git a/test/staging/sm/Function/spread-iterator-primitive.js b/test/staging/sm/Function/spread-iterator-primitive.js index 5c77f5ec9c..cc8bdb7dcd 100644 --- a/test/staging/sm/Function/spread-iterator-primitive.js +++ b/test/staging/sm/Function/spread-iterator-primitive.js @@ -32,6 +32,6 @@ for (let primitive of primitives) { return primitive; } }; - assertThrowsInstanceOf(() => f(...arg), TypeError); + assert.throws(TypeError, () => f(...arg)); }