-
-
Save leobalter/d5ddfd403c0b92333201ea7f8872d5a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*--- | |
description: > | |
Error thrown when invoking the instance's `then` method (rejecting Promise) | |
esid: sec-promise.allSettled | |
info: | | |
6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability). | |
7. If result is an abrupt completion, then | |
a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result). | |
b. IfAbruptRejectPromise(result, promiseCapability). | |
Runtime Semantics: PerformPromiseAllSettled | |
z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »). | |
flags: [async] | |
---*/ | |
var promise = new Promise(function() {}); | |
var error = new Test262Error(); | |
promise.then = function() { | |
throw error; | |
}; | |
Promise.allSettled([promise]).then(function() { | |
throw new Test262Error('The promise should be rejected'); | |
}, function(reason) { | |
assert.sameValue(reason, error); | |
}).then($DONE, $DONE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
var allSettled = require('promise.allsettled'); | |
allSettled.shim(); // will be a no-op if not needed | |
var promise = new Promise(function() {}); | |
var error = new Error(); | |
promise.then = function() { | |
throw error; | |
}; | |
function $DONE(arg) { | |
assert.strictEqual(arg, undefined); | |
console.log('ok'); | |
} | |
Promise.all([promise]).then(function() { | |
throw 'The promise should be rejected'; | |
}, function(reason) { | |
assert.strictEqual(reason, error); | |
}).then($DONE, $DONE); | |
Promise.allSettled([promise]) // shim is throwing here and not rejecting the promise per spec text | |
.then(function() { | |
throw 'The promise should be rejected'; | |
}, function(reason) { | |
assert.strictEqual(reason, error); // this is the current spec text today | |
}).then($DONE, $DONE); | |
Promise.allSettled([promise]) | |
.then(function(arr) { | |
arr[0] // sounds like it should be { status: 'rejected', reason: error } | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment