diff --git a/harness/isConstructor.js b/harness/isConstructor.js index 5cad484242..b23001c5e5 100644 --- a/harness/isConstructor.js +++ b/harness/isConstructor.js @@ -8,6 +8,10 @@ defines: [isConstructor] ---*/ function isConstructor(f) { + if (typeof f !== "function") { + throw new Test262Error("isConstructor invoked with a non-function value"); + } + try { Reflect.construct(function(){}, [], f); } catch (e) { diff --git a/test/built-ins/Promise/prototype/finally/rejected-observable-then-calls-argument.js b/test/built-ins/Promise/prototype/finally/rejected-observable-then-calls-argument.js index 43306e8aca..76ba16dfaf 100644 --- a/test/built-ins/Promise/prototype/finally/rejected-observable-then-calls-argument.js +++ b/test/built-ins/Promise/prototype/finally/rejected-observable-then-calls-argument.js @@ -40,10 +40,6 @@ var expected = [ var then = Promise.prototype.then; Promise.prototype.then = function(resolve, reject) { - assert.sameValue(isConstructor(reject), false, 'isConstructor(reject) must return false'); - assert.throws(TypeError, () => { - new reject(); - }, '`new reject()` throws TypeError'); assert.sameValue( resolve.length, @@ -57,6 +53,13 @@ Promise.prototype.then = function(resolve, reject) { ); if (calls === 0) { assert.throws(MyError, resolve, '`resolve()` throws `MyError`'); + assert.sameValue(arguments.length, 1, '`then` invoked with one argument'); + } else { + assert.sameValue(isConstructor(reject), false, 'isConstructor(reject) must return false'); + assert.throws(TypeError, () => { + new reject(); + }, '`new reject()` throws TypeError'); + assert.sameValue(arguments.length, 2, '`then` invoked with two arguments'); } calls += 1; diff --git a/test/harness/isConstructor.js b/test/harness/isConstructor.js index 54460ce149..49504996ca 100644 --- a/test/harness/isConstructor.js +++ b/test/harness/isConstructor.js @@ -13,16 +13,16 @@ features: [generators, Reflect.construct] assert.sameValue(typeof isConstructor, "function"); -assert.sameValue(isConstructor(), false); -assert.sameValue(isConstructor(undefined), false); -assert.sameValue(isConstructor(null), false); -assert.sameValue(isConstructor(123), false); -assert.sameValue(isConstructor(true), false); -assert.sameValue(isConstructor(false), false); -assert.sameValue(isConstructor("string"), false); +assert.throws(Test262Error, () => isConstructor(), "no argument"); +assert.throws(Test262Error, () => isConstructor(undefined), "undefined"); +assert.throws(Test262Error, () => isConstructor(null), "null"); +assert.throws(Test262Error, () => isConstructor(123), "number"); +assert.throws(Test262Error, () => isConstructor(true), "boolean - true"); +assert.throws(Test262Error, () => isConstructor(false), "boolean - false"); +assert.throws(Test262Error, () => isConstructor("string"), "string"); -assert.sameValue(isConstructor({}), false); -assert.sameValue(isConstructor([]), false); +assert.throws(Test262Error, () => isConstructor({}), "Object instance"); +assert.throws(Test262Error, () => isConstructor([]), "Array instance"); assert.sameValue(isConstructor(function(){}), true); assert.sameValue(isConstructor(function*(){}), false);