mirror of https://github.com/tc39/test262.git
`Promise.prototype.finally` thunks have a length of 0
This commit is contained in:
parent
5c9b5ed610
commit
0ebbdf0395
|
@ -21,12 +21,22 @@ Promise.reject(new Test262Error())
|
|||
.finally(function() {})
|
||||
.then($DONE, $DONE);
|
||||
|
||||
var then = Promise.prototype.then;
|
||||
Promise.prototype.then = function(thrower) {
|
||||
assert(!isConstructor(thrower));
|
||||
assert.sameValue(thrower.length, 1);
|
||||
assert.sameValue(thrower.name, '');
|
||||
assert.throws(Test262Error, thrower);
|
||||
var calls = 0;
|
||||
var expected = [
|
||||
{ length: 0, name: '' },
|
||||
{ length: 1, name: '' }
|
||||
];
|
||||
|
||||
return then.call(this, thrower);
|
||||
var then = Promise.prototype.then;
|
||||
Promise.prototype.then = function(resolve) {
|
||||
assert(!isConstructor(resolve));
|
||||
assert.sameValue(resolve.length, expected[calls].length);
|
||||
assert.sameValue(resolve.name, expected[calls].name);
|
||||
if (calls === 0) {
|
||||
assert.throws(Test262Error, resolve);
|
||||
}
|
||||
|
||||
calls += 1;
|
||||
|
||||
return then.call(this, resolve);
|
||||
};
|
||||
|
|
|
@ -23,12 +23,20 @@ Promise.resolve(value)
|
|||
.finally(function() {})
|
||||
.then($DONE, $DONE);
|
||||
|
||||
var then = Promise.prototype.then;
|
||||
Promise.prototype.then = function(valueThunk) {
|
||||
assert(!isConstructor(valueThunk));
|
||||
assert.sameValue(valueThunk.length, 1);
|
||||
assert.sameValue(valueThunk.name, '');
|
||||
assert.sameValue(valueThunk(), value);
|
||||
var calls = 0;
|
||||
var expected = [
|
||||
{ length: 0, name: '' },
|
||||
{ length: 1, name: '' }
|
||||
];
|
||||
|
||||
return then.call(this, valueThunk);
|
||||
var then = Promise.prototype.then;
|
||||
Promise.prototype.then = function(resolve) {
|
||||
assert(!isConstructor(resolve));
|
||||
assert.sameValue(resolve.length, expected[calls].length);
|
||||
assert.sameValue(resolve.name, expected[calls].name);
|
||||
if (calls === 0) {
|
||||
assert.sameValue(resolve(), value);
|
||||
}
|
||||
|
||||
return then.call(this, resolve);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue