-
Notifications
You must be signed in to change notification settings - Fork 460
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
Tests for Promise.withResolvers #3910
Comments
Thanks! Added some suggestions from examining the existing tests for |
Assuming the built-ins/Promise/withResolvers directory contains all tests, what I am missing is test(s) that call the resolve/reject functions and make sure the promise object is correctly rejected/resolved. |
thanks for the additions @ptomato ! i'm not sure i understand the first or last items in the sub-list you added there. also do you know of an example of an existing Promise method that has a test for |
Sure, for the first item in the sub-list ("throws"): I meant we should test the case where the function body of the receiver's constructor throws an exception. Like this: function MyPromise() {
throw new Error("you can't call me");
}
Promise.withResolvers.call(MyPromise); For the last item in the sub-list ("value of promise property if it returns a value that isn't an instance of itself") - since a constructor can override the object that it would normally return, and return an entirely different object that isn't an instance of that constructor, or isn't even a Promise. Like this: class MyPromise extends Promise {
constructor(...args) {
super(...args);
return { then: Promise.prototype.then };
}
}
Promise.withResolvers.call(MyPromise); For an existing example of "Reciever constructor does not have to extend built-in Promise" I don't know of one. But I did find https://github.com/tc39/test262/blob/main/test/built-ins/Promise/all/S25.4.4.1_A4.1_T1.js which is a test for the opposite, that |
I was asked to open this issue to track test completeness for the Stage 3 Promise.withResolvers method. I'm pretty new to this so any suggestions for things that should go in this tracker would be very appreciated.
length.js
,name.js
,prop-desc.js
,not-a-constructor.js
,builtin.js
)Object.prototype
prototyperesolve
,reject
, andpromise
promise
property on the produced object is an instance of the receiverresolve
andreject
properties are both 1-place functionsPromise
promise
property if it returns a value that isn't an instance of itselfThe text was updated successfully, but these errors were encountered: