-
Notifications
You must be signed in to change notification settings - Fork 475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Promise.prototype.finally: add missing tests #1398
Conversation
var p = Promise.reject().finally(() => FooPromise.reject()); | ||
|
||
assert.sameValue(p instanceof Promise, true); | ||
assert.sameValue(p instanceof FooPromise, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be false because .then()
in Step 7 of Promise.prototype.finally
is called on the receiver of finally
which is Promise
.
} | ||
|
||
FooPromise.reject().finally(() => {}).then($DONE).catch(() => { | ||
assert.sameValue(6, count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be 7 -- the first 6 promises are created same as the below test and +1 for the extra .catch()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha, thanks
var p = Promise.resolve().finally(() => FooPromise.resolve()); | ||
|
||
assert.sameValue(p instanceof Promise, true); | ||
assert.sameValue(p instanceof FooPromise, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be false, same as above test
Thanks! With your feedback, the failures drop to 8 in latest node :-) |
var oldThen = Promise.prototype.then; | ||
Promise.prototype.then = () => { called = true; }; | ||
Promise.prototype.finally.call(p); | ||
assertTrue(called); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be assert.sameValue(called, true);
Can you list the failing tests? All the 5 new tests pass for me locally:
|
Sure, with the latest update: $ node --version
v9.4.0
$ npx test262-harness --hostType=node --hostPath=`which node` --hostArgs="--harmony-promise-finally" test/built-ins/Promise/prototype/finally/*
FAIL test/built-ins/Promise/prototype/finally/species-constructor.js
Test did not run to completion
FAIL test/built-ins/Promise/prototype/finally/species-constructor.js
Test did not run to completion
FAIL test/built-ins/Promise/prototype/finally/subclass-reject-count.js
Test did not run to completion
FAIL test/built-ins/Promise/prototype/finally/subclass-reject-count.js
Test did not run to completion
FAIL test/built-ins/Promise/prototype/finally/subclass-resolve-count.js
Test did not run to completion
FAIL test/built-ins/Promise/prototype/finally/subclass-resolve-count.js
Test did not run to completion
FAIL test/built-ins/Promise/prototype/finally/this-value-non-promise.js
Expected no error, got TypeError: Method Promise.prototype.finally called on incompatible receiver [object Object]
FAIL test/built-ins/Promise/prototype/finally/this-value-non-promise.js
Expected no error, got TypeError: Method Promise.prototype.finally called on incompatible receiver [object Object]
Ran 46 tests
38 passed
8 failed |
I fixed this recently in V8 (~month ago) so may be node v9 doesn't have the fix. I'm not sure about the rest. They all run to completion (and pass the test) in V8 for me locally. In fact, I have these tests checked in to V8 already here: I wonder if it's something to do with the harness. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed this in the earlier review
@@ -22,4 +22,4 @@ new FooPromise(r => r()) | |||
.then(() => { | |||
assert.sameValue(count, 6, "6 new promises were created"); | |||
$DONE(); | |||
}); | |||
}, $DONE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be $ERROR
because we shouldn't be catching anything
} | ||
} | ||
|
||
FooPromise.reject().finally(() => {}).then($DONE).catch(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The then callback should take $ERROR
as resolving would pass the test silently
FooPromise.resolve().finally(() => {}).then(() => { | ||
assert.sameValue(6, count); | ||
$DONE(); | ||
}, $DONE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, the catch callback should be $ERROR
Thanks @ljharb 💯 |
Per:
Closes #866.
cc @gsathya, do you think these tests are correct? v8 fails 12 of them.