mirror of
https://github.com/tc39/test262.git
synced 2025-07-19 03:54:36 +02:00
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() {})
|
.finally(function() {})
|
||||||
.then($DONE, $DONE);
|
.then($DONE, $DONE);
|
||||||
|
|
||||||
var then = Promise.prototype.then;
|
var calls = 0;
|
||||||
Promise.prototype.then = function(thrower) {
|
var expected = [
|
||||||
assert(!isConstructor(thrower));
|
{ length: 0, name: '' },
|
||||||
assert.sameValue(thrower.length, 1);
|
{ length: 1, name: '' }
|
||||||
assert.sameValue(thrower.name, '');
|
];
|
||||||
assert.throws(Test262Error, thrower);
|
|
||||||
|
|
||||||
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() {})
|
.finally(function() {})
|
||||||
.then($DONE, $DONE);
|
.then($DONE, $DONE);
|
||||||
|
|
||||||
var then = Promise.prototype.then;
|
var calls = 0;
|
||||||
Promise.prototype.then = function(valueThunk) {
|
var expected = [
|
||||||
assert(!isConstructor(valueThunk));
|
{ length: 0, name: '' },
|
||||||
assert.sameValue(valueThunk.length, 1);
|
{ length: 1, name: '' }
|
||||||
assert.sameValue(valueThunk.name, '');
|
];
|
||||||
assert.sameValue(valueThunk(), value);
|
|
||||||
|
|
||||||
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…
x
Reference in New Issue
Block a user