Skip to content

Commit

Permalink
Editorial: add PromiseCapability Record assertions (tc39#2050)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 1, 2020
1 parent 34d2050 commit 397b9d9
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -24102,7 +24102,7 @@ <h1>Runtime Semantics: HostImportModuleDynamically ( _referencingScriptOrModule_

<emu-clause id="sec-finishdynamicimport" aoid="FinishDynamicImport">
<h1>Runtime Semantics: FinishDynamicImport ( _referencingScriptOrModule_, _specifier_, _promiseCapability_, _completion_ )</h1>
<p>The abstract operation FinishDynamicImport takes arguments _referencingScriptOrModule_, _specifier_, _promiseCapability_, and _completion_. FinishDynamicImport completes the process of a dynamic import originally started by an <emu-xref href="#sec-import-calls">`import()`</emu-xref> call, resolving or rejecting the promise returned by that call as appropriate according to _completion_. It is performed by host environments as part of HostImportModuleDynamically. It performs the following steps when called:</p>
<p>The abstract operation FinishDynamicImport takes arguments _referencingScriptOrModule_, _specifier_, _promiseCapability_ (a PromiseCapability Record), and _completion_. FinishDynamicImport completes the process of a dynamic import originally started by an <emu-xref href="#sec-import-calls">`import()`</emu-xref> call, resolving or rejecting the promise returned by that call as appropriate according to _completion_. It is performed by host environments as part of HostImportModuleDynamically. It performs the following steps when called:</p>

<emu-alg>
1. If _completion_ is an abrupt completion, then perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _completion_.[[Value]] »).
Expand Down Expand Up @@ -39019,7 +39019,7 @@ <h1>Properties of Async-from-Sync Iterator Instances</h1>

<emu-clause id="sec-asyncfromsynciteratorcontinuation" aoid="AsyncFromSyncIteratorContinuation">
<h1>AsyncFromSyncIteratorContinuation ( _result_, _promiseCapability_ )</h1>
<p>The abstract operation AsyncFromSyncIteratorContinuation takes arguments _result_ and _promiseCapability_. It performs the following steps when called:</p>
<p>The abstract operation AsyncFromSyncIteratorContinuation takes arguments _result_ and _promiseCapability_ (a PromiseCapability Record). It performs the following steps when called:</p>

<emu-alg>
1. Let _done_ be IteratorComplete(_result_).
Expand Down Expand Up @@ -39572,7 +39572,7 @@ <h1>AsyncGeneratorRequest Records</h1>
</tr>
<tr>
<td>[[Capability]]</td>
<td>A PromiseCapability record</td>
<td>A PromiseCapability Record</td>
<td>The promise capabilities associated with this request.</td>
</tr>
</tbody>
Expand Down Expand Up @@ -39780,7 +39780,7 @@ <h1>Promise Abstract Operations</h1>

<emu-clause id="sec-promisecapability-records">
<h1>PromiseCapability Records</h1>
<p>A PromiseCapability is a Record value used to encapsulate a promise object along with the functions that are capable of resolving or rejecting that promise object. PromiseCapability Records are produced by the NewPromiseCapability abstract operation.</p>
<p>A <dfn>PromiseCapability Record</dfn> is a Record value used to encapsulate a promise object along with the functions that are capable of resolving or rejecting that promise object. PromiseCapability Records are produced by the NewPromiseCapability abstract operation.</p>
<p>PromiseCapability Records have the fields listed in <emu-xref href="#table-57"></emu-xref>.</p>
<emu-table id="table-57" caption="PromiseCapability Record Fields">
<table>
Expand Down Expand Up @@ -39987,7 +39987,7 @@ <h1>NewPromiseCapability ( _C_ )</h1>
<emu-alg>
1. If IsConstructor(_C_) is *false*, throw a *TypeError* exception.
1. NOTE: _C_ is assumed to be a constructor function that supports the parameter conventions of the Promise constructor (see <emu-xref href="#sec-promise-executor"></emu-xref>).
1. Let _promiseCapability_ be the PromiseCapability { [[Promise]]: *undefined*, [[Resolve]]: *undefined*, [[Reject]]: *undefined* }.
1. Let _promiseCapability_ be the PromiseCapability Record { [[Promise]]: *undefined*, [[Resolve]]: *undefined*, [[Reject]]: *undefined* }.
1. Let _steps_ be the algorithm steps defined in <emu-xref href="#sec-getcapabilitiesexecutor-functions" title></emu-xref>.
1. Let _executor_ be ! CreateBuiltinFunction(_steps_, &laquo; [[Capability]] &raquo;).
1. Set _executor_.[[Capability]] to _promiseCapability_.
Expand Down Expand Up @@ -40099,6 +40099,7 @@ <h1>NewPromiseReactionJob ( _reaction_, _argument_ )</h1>
1. If _promiseCapability_ is *undefined*, then
1. Assert: _handlerResult_ is not an abrupt completion.
1. Return NormalCompletion(~empty~).
1. Assert: _promiseCapability_ is a PromiseCapability Record.
1. If _handlerResult_ is an abrupt completion, then
1. Let _status_ be Call(_promiseCapability_.[[Reject]], *undefined*, &laquo; _handlerResult_.[[Value]] &raquo;).
1. Else,
Expand Down Expand Up @@ -40213,10 +40214,9 @@ <h1>Runtime Semantics: GetPromiseResolve ( _promiseConstructor_ )</h1>

<emu-clause id="sec-performpromiseall" aoid="PerformPromiseAll">
<h1>Runtime Semantics: PerformPromiseAll ( _iteratorRecord_, _constructor_, _resultCapability_, _promiseResolve_ )</h1>
<p>The abstract operation PerformPromiseAll takes arguments _iteratorRecord_, _constructor_, _resultCapability_, and _promiseResolve_. It performs the following steps when called:</p>
<p>The abstract operation PerformPromiseAll takes arguments _iteratorRecord_, _constructor_, _resultCapability_ (a PromiseCapability Record), and _promiseResolve_. It performs the following steps when called:</p>
<emu-alg>
1. Assert: IsConstructor(_constructor_) is *true*.
1. Assert: _resultCapability_ is a PromiseCapability Record.
1. Assert: IsCallable(_promiseResolve_) is *true*.
1. Let _values_ be a new empty List.
1. Let _remainingElementsCount_ be the Record { [[Value]]: 1 }.
Expand Down Expand Up @@ -40296,10 +40296,9 @@ <h1>Promise.allSettled ( _iterable_ )</h1>

<emu-clause id="sec-performpromiseallsettled" aoid="PerformPromiseAllSettled">
<h1>Runtime Semantics: PerformPromiseAllSettled ( _iteratorRecord_, _constructor_, _resultCapability_, _promiseResolve_ )</h1>
<p>The abstract operation PerformPromiseAllSettled takes arguments _iteratorRecord_, _constructor_, _resultCapability_, and _promiseResolve_. It performs the following steps when called:</p>
<p>The abstract operation PerformPromiseAllSettled takes arguments _iteratorRecord_, _constructor_, _resultCapability_ (a PromiseCapability Record), and _promiseResolve_. It performs the following steps when called:</p>
<emu-alg>
1. Assert: ! IsConstructor(_constructor_) is *true*.
1. Assert: _resultCapability_ is a PromiseCapability Record.
1. Assert: IsCallable(_promiseResolve_) is *true*.
1. Let _values_ be a new empty List.
1. Let _remainingElementsCount_ be the Record { [[Value]]: 1 }.
Expand Down Expand Up @@ -40425,10 +40424,9 @@ <h1>Promise.race ( _iterable_ )</h1>

<emu-clause id="sec-performpromiserace" aoid="PerformPromiseRace">
<h1>Runtime Semantics: PerformPromiseRace ( _iteratorRecord_, _constructor_, _resultCapability_, _promiseResolve_ )</h1>
<p>The abstract operation PerformPromiseRace takes arguments _iteratorRecord_, _constructor_, _resultCapability_, and _promiseResolve_. It performs the following steps when called:</p>
<p>The abstract operation PerformPromiseRace takes arguments _iteratorRecord_, _constructor_, _resultCapability_ (a PromiseCapability Record), and _promiseResolve_. It performs the following steps when called:</p>
<emu-alg>
1. Assert: IsConstructor(_constructor_) is *true*.
1. Assert: _resultCapability_ is a PromiseCapability Record.
1. Assert: IsCallable(_promiseResolve_) is *true*.
1. Repeat,
1. Let _next_ be IteratorStep(_iteratorRecord_).
Expand Down Expand Up @@ -40600,12 +40598,10 @@ <h1>Promise.prototype.then ( _onFulfilled_, _onRejected_ )</h1>

<emu-clause id="sec-performpromisethen" aoid="PerformPromiseThen">
<h1>PerformPromiseThen ( _promise_, _onFulfilled_, _onRejected_ [ , _resultCapability_ ] )</h1>
<p>The abstract operation PerformPromiseThen takes arguments _promise_, _onFulfilled_, and _onRejected_ and optional argument _resultCapability_. It performs the &ldquo;then&rdquo; operation on _promise_ using _onFulfilled_ and _onRejected_ as its settlement actions. If _resultCapability_ is passed, the result is stored by updating _resultCapability_'s promise. If it is not passed, then PerformPromiseThen is being called by a specification-internal operation where the result does not matter. It performs the following steps when called:</p>
<p>The abstract operation PerformPromiseThen takes arguments _promise_, _onFulfilled_, and _onRejected_ and optional argument _resultCapability_ (a PromiseCapability Record). It performs the &ldquo;then&rdquo; operation on _promise_ using _onFulfilled_ and _onRejected_ as its settlement actions. If _resultCapability_ is passed, the result is stored by updating _resultCapability_'s promise. If it is not passed, then PerformPromiseThen is being called by a specification-internal operation where the result does not matter. It performs the following steps when called:</p>
<emu-alg>
1. Assert: IsPromise(_promise_) is *true*.
1. If _resultCapability_ is present, then
1. Assert: _resultCapability_ is a PromiseCapability Record.
1. Else,
1. If _resultCapability_ is not present, then
1. Set _resultCapability_ to *undefined*.
1. If IsCallable(_onFulfilled_) is *false*, then
1. Set _onFulfilled_ to *undefined*.
Expand Down Expand Up @@ -40803,7 +40799,7 @@ <h1>Async Functions Abstract Operations</h1>

<emu-clause id="sec-async-functions-abstract-operations-async-function-start" aoid="AsyncFunctionStart">
<h1>AsyncFunctionStart ( _promiseCapability_, _asyncFunctionBody_ )</h1>
<p>The abstract operation AsyncFunctionStart takes arguments _promiseCapability_ and _asyncFunctionBody_. It performs the following steps when called:</p>
<p>The abstract operation AsyncFunctionStart takes arguments _promiseCapability_ (a PromiseCapability Record) and _asyncFunctionBody_. It performs the following steps when called:</p>
<emu-alg>
1. Let _runningContext_ be the running execution context.
1. Let _asyncContext_ be a copy of _runningContext_.
Expand Down

0 comments on commit 397b9d9

Please sign in to comment.