-
Notifications
You must be signed in to change notification settings - Fork 107
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
Rejecting with a promise is not fully tested #59
Comments
I don't understand the |
@ziriax It will probably be hard for us to comment, since we don't understand your code nearly as well as you do. If you could provide some sort of minimal test case that shows a potential problem, such as a particular test not matching a part of the Promises/A+ spec, that'd be extremely helpful. |
Sorry for not making my question clear enough. I don't understand my own code that much either ;-) I tweaked it until all the specs passed, some of them were really hard to get right. Let me try to explain my question in detail, with an example. Consider the following code:
What should be the correct output? If I keep my promise implementation as initially pasted, I get the output:
So However, if I modify my
In this case Only one of the two behaviors can be correct, but I don't know which one. So this means that I have two different implementations, both of them passing all the tests, but with different behavior. The test suite doesn't seem to dictate the correct behavior, or at least not in the context of my own simple promise implementation. What confused me in the A+ spec was
It's not clear to me what to do when the reason Thanks a lot, |
That means you found a bug in the test coverage; nice!
You should follow the spec, and reject |
Reject is verbatim. IOW, you shouldn't attempt to resolve |
jinx again! :) |
Nice catch! |
For learning promises, I made my own little implementation, see code below. I'm a Javascript newbie, so Douglas, don't be too hard on me please ;-)
For simplicity, it uses
process.nextTick
, so it only works in nodejs for now.However, all 872 specs of your test suite pass, whether or not I 'adopt the state' of a 'thenable' passed as an argument to the
reject
method. See the single comment in the code.What is the correct behavior?
Thanks a lot,
Peter Verswyvelen
The text was updated successfully, but these errors were encountered: