Skip to content
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

Test incorrect state transitions of promises #29

Closed
jnicklas opened this issue Apr 15, 2013 · 3 comments
Closed

Test incorrect state transitions of promises #29

jnicklas opened this issue Apr 15, 2013 · 3 comments

Comments

@jnicklas
Copy link

It seems like the first part of the Promises/A+ spec isn't tested:

A promise must be in one of three states: pending, fulfilled, or rejected.

When pending, a promise:
  may transition to either the fulfilled or rejected state.
When fulfilled, a promise:
  must not transition to any other state.
  must have a fulfillment value, which must not change.
When rejected, a promise:
  must not transition to any other state.
  must have a rejection reason, which must not change.

I wrote a promise implementation which passed all tests, but failed to protect against incorrect state transitions. It should be fairly simple to write these tests given the existing adapter interface, I think.

I'd be willing to write these tests, I just wanted to run this by you first before I spend the time on creating a pull request.

@ForbesLindesay
Copy link
Member

How do you plan to add these tests... I'm pretty sure we already test for multiple resolve and multiple reject calls. Of course a promise could offer an additional API method called mutate() which let you mutate the state after it was resolved, but I can't see how we could test for that.

@briancavalier
Copy link
Member

@jnicklas Could you point us to a specific example, possibly from your implementation. For example, does your promise implementation allow an implementation-specific way of observing (perhaps via a public promise.state property?) a promise's state? As @ForbesLindesay says, we can only test against the then API, since that's the only specified way to observe a promise.

If you can show an example, though, that might help us understand if there's a hole in the spec and tests. Thanks!

@briancavalier
Copy link
Member

@jnicklas If you can provide more info or examples here, we're happy to continue the discussion. If we haven't heard from you in two days, we'll consider this resolved or a non-issue. Thanks!

@domenic domenic closed this as completed May 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants