[await-dictionary] add failure case and edge case tests#5041
[await-dictionary] add failure case and edge case tests#5041danialasaria wants to merge 2 commits intotc39:mainfrom
Conversation
Cover remaining items from the testing plan (tc39#4886): - NewPromiseCapability: constructor throws, executor not callable - GetPromiseResolve: Get accessor throws - promiseResolve call throws during iteration - allKeyed rejection ordering (2nd and last to settle) - Synchronous thenables hitting remainingElementsCount step 8 - Exotic object: [[OwnPropertyKeys]] throws - Exotic object: [[GetOwnProperty]] throws - Exotic object: [[GetOwnProperty]] returns undefined (key skipped)
- capability-executor-not-callable: add Object.defineProperty poison on 'resolve' to detect wrong evaluation order, add fn6 case (Number, String) - invoke-then-error-reject: new test for Invoke(nextPromise, "then") throwing - invoke-then-get-error-reject: new test for Get(nextPromise, "then") throwing - resolve-before-loop-exit: switch Object.keys to Reflect.ownKeys - getownproperty-not-enumerable: new test for non-enumerable keys being skipped Made-with: Cursor
578f02d to
6e2fa0c
Compare
acutmore
left a comment
There was a problem hiding this comment.
Could we also have a test that a custom constructor is being 'constructed' rather than 'called'.
If we can use new.target we can check like:
var error = new Test262Error();
function Constructor(executor) {
if (new.target !== Constructor) {
throw error
}
}We can also have assertions that validate the arguments passed to a custom constructor are correct: should only be one argument: the executor. And it should be a function with length 2.
|
|
||
| Promise.allSettledKeyed.call(Constructor, input); | ||
|
|
||
| assert.sameValue(callCount, 1, "callCount after call to allSettledKeyed()"); |
There was a problem hiding this comment.
Could we either move the callCount to after the assertions, or have a separate count for the start and end of the callback. Otherwise technically the assertions could reject and they are swallowed by the function caller yet the test would pass (unless the harness has some tracking logic to guarantee a test fails if a harness assertion errors, rather than relying on the exception bubbling up)
Summary
This PR adds the remaining failure-case and edge-case coverage for the await-dictionary proposal's Promise keyed combinators:
Promise.allKeyedPromise.allSettledKeyedIt follows the runtime/behavioral tests PR (#4932) and completes the testing plan from #4886.
What this PR covers
NewPromiseCapability failures (sync throws)
ctx-ctor-throws.js)capability-executor-not-callable.js)GetPromiseResolve failures (async rejections)
Get(constructor, "resolve")accessor throws (invoke-resolve-get-error-reject.js)promiseResolvefunction throws (invoke-resolve-error-reject.js)Invoke(then) failures (async rejections)
Get(nextPromise, "then")accessor throws (invoke-then-get-error-reject.js)nextPromise.then(...)throws (invoke-then-error-reject.js)allKeyed rejection ordering
reject-second.js)reject-last.js)Synchronous thenables (step 8 edge case)
onFulfilledduring the loop, causingremainingElementsCountto reach zero before the loop exits (resolve-before-loop-exit.js)Exotic object abrupt completions (Proxy)
[[OwnPropertyKeys]]throws (ownkeys-throws.js)[[GetOwnProperty]]throws (getownproperty-throws.js)[[GetOwnProperty]]returnsundefined-- key is skipped (getownproperty-returns-undefined.js)Property descriptor filtering
getownproperty-not-enumerable.js)Notes
asyncTestfromasyncHelpers.jsper reviewer feedback on [await-dictionary] add runtime keyed Promise combinator tests #4932assert.throws(...)features: [await-dictionary]; Proxy tests additionally gate onProxyPromise.all/Promise.allSettledtest suitescapability-executor-not-callableincludes poisonedresolvegetters (matchingPromise.allcounterpart) to detect wrong evaluation orderWhat this PR does not cover
This completes all items from the testing plan (#4886).
References
Promise.allKeyedandPromise.allSettledKeyedtesting plan #4886