[await-dictionary] add runtime keyed Promise combinator tests#4932
[await-dictionary] add runtime keyed Promise combinator tests#4932danialasaria wants to merge 5 commits intotc39:mainfrom
Conversation
Cover shared failure/success behavior for Promise.allKeyed and Promise.allSettledKeyed, including non-object rejection, non-constructor context, key ordering, and allSettled result-shape outcomes.
d6a6c31 to
50702d4
Compare
| resolveThird('third'); | ||
| resolveSecond('second'); | ||
| resolveFirst('first'); |
There was a problem hiding this comment.
I wonder if it would be better to resolve 2nd, 3rd, 1st. To avoid the test passing for an incorrect implementation that adds them in reverse resolved order (e.g. it stores them in a stack and then pops them off).
There was a problem hiding this comment.
Good call — changed to resolve in 2nd, 3rd, 1st order so a stack-based implementation wouldn't accidentally pass.
| Promise.allKeyed({}).then(function(result) { | ||
| assert.sameValue(Object.getPrototypeOf(result), null); | ||
| assert.sameValue(result.hasOwnProperty, undefined); | ||
| assert.compareArray(Object.keys(result), []); |
There was a problem hiding this comment.
I'm not sure what the precedent here is, but I'm wondering if it would be better to use Reflect.allKeys or Object.getOwnPropertyDescriptors as these are exhaustive whereas Object.keys will ignore non-enumerable and symbol keys.
There was a problem hiding this comment.
I think so too! Switched to Reflect.ownKeys which covers non-enumerable and symbol keys as well.
| }); | ||
| } | ||
|
|
||
| checkRejects(undefined) |
There was a problem hiding this comment.
I'm not sure what the precedent is here, but it should also reject for a BigInt. The test currently tests all other primitives. I presume it might be to make the test work for engines that don't support BigInt - if so maybe we can have a separate test or feature detect them?
There was a problem hiding this comment.
Added a separate arg-not-object-reject-bigint.js test file with a features: [BigInt] flag so engines without BigInt support aren't gated!
…nt coverage - Change key-order-preserved settle sequence to 2nd, 3rd, 1st to avoid false passes from reverse-order implementations - Use Reflect.ownKeys instead of Object.keys in empty-object assertions for exhaustive own-key verification - Add separate BigInt rejection tests gated behind BigInt feature flag
607531a to
589f4da
Compare
Summary
This PR adds the first runtime/behavioral coverage for the await-dictionary proposal’s Promise keyed combinators:
Promise.allKeyedPromise.allSettledKeyedIt follows the initial boilerplate-only PR and focuses on high-signal success/failure semantics and ordering behavior.
What this PR covers
Shared coverage for both methods
For both
Promise.allKeyedandPromise.allSettledKeyed, this PR adds tests for:promisesis not an Object (primitive matrix:undefined,null, number, string, boolean, symbol)NewPromiseCapabilitypath)resolveis non-callable (GetPromiseResolve/IfAbruptRejectPromisepath){}to an empty null-prototype result objectPromise.allKeyed-specificPromise.allSettledKeyed-specific{ status: "fulfilled", value }{ status: "rejected", reason }Notes
features: [await-dictionary].Promise/allandPromise/allSettled.What this PR does not cover
This PR intentionally leaves some deeper edge paths for follow-up work, including:
promiseResolvethrowing or returning a non-thenable[[OwnPropertyKeys]]/[[GetOwnProperty]]remainingElementsCountstep-8 edge behaviorReferences