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

Edge case? #42

Closed
vanhelgen opened this issue Oct 9, 2013 · 1 comment
Closed

Edge case? #42

vanhelgen opened this issue Oct 9, 2013 · 1 comment

Comments

@vanhelgen
Copy link

Hi there, I was testing my little Promise/A+ library against the 2.0.0 test suite and after some fiddling it finally passed all tests. Then I got back to testing to see how it's working in the wild and I found this issue; here is my contrived test case:

new Promise(function (resolve, reject) {
    var val = Math.random();

    if (val >= 0.5) {
        resolve(val);
    }
    else {
        reject(new Error('Value "' + val + '" too low.'));
    }
})
.then(function (value) {
    console.log('  promise.then.resolved', arguments);
    return 100 * value;
})
.then(null, function (reason) {
    console.warn('  next.promise.then.rejected', arguments);
    return 'error handled';
});

What I would have expected is:
val >= 0.5 -> log('promise.then.resolved')
val < 0.5 -> warn('next.promise.then.rejected')

but instead I saw the first promise resolved after val >= 0.5 but the rejection of val < 0.5 didn't propagate to the next promise so in this case there would be no activity.
val >= 0.5 -> log ...
val < 0.5 -> ...

I was wondering if this is the expected behavior; is it just me not getting the specs or is this a bug in the test suite?

Right now I've fixed this in my lib and the tests still pass - don't know what to make of it...

thx

@domenic
Copy link
Member

domenic commented Oct 13, 2013

So you are saying that you created a promise library that passed all the tests, but such that

new Promise(function (resolve, reject) {
  reject();
})
.then(function () {
})
.then(null, function () {
  console.log("never gets here, even though it should?");
});

outputs nothing? That sounds like a gap in the test suite coverage, yeah...

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

2 participants