domenic / promise-tests

DEPRECATED: use https://github.com/promises-aplus/promises-tests instead!
https://github.com/promises-aplus/promises-tests
Do What The F*ck You Want To Public License
61 stars 10 forks source link

Allow promises libraries to throw #1

Closed wycats closed 12 years ago

wycats commented 12 years ago

This pull request adds support for promises libraries that choose to throw when they are resolved or rejected after being resolved or rejected. At present, the test suite requires that libraries silently swallow the attempt.

domenic commented 12 years ago

Hmm, so first, I agree that by the Promises/A spec libraries should be allowed to throw upon disallowed state transitions. I'd probably implement it more simply, with just a try/catch around the possibly-throwing operation. Will integrate.

However, the intent of the Promises/A proposal (in particular requirement 3.2) disallows throwing in this case. In particular, you should be able to give a resolver (i.e. a fulfill and/or reject function) to "mutually suspicious consumers," such that they "race" to resolve the promise, with neither knowing the state of the promise or in particular observing the actions of the other.

I'll add tests for this additional intent under a new, complimentary test suite.

Thanks for this!