summaryrefslogtreecommitdiff
path: root/test/built-ins/AsyncGeneratorPrototype/next/iterator-result-prototype.js
diff options
context:
space:
mode:
authorValerie <spectranaut@gmail.com>2018-03-02 09:44:23 -0500
committerLeo Balter <leonardo.balter@gmail.com>2018-03-02 09:44:23 -0500
commite14a9ad9fefaf94454695e74db9873282ea22880 (patch)
treee8794a10e3a3f3049c2b1bb1da7ab4afab333efa /test/built-ins/AsyncGeneratorPrototype/next/iterator-result-prototype.js
parent4a3e19b3e4f04be2d747ca5d7529115f5cf85169 (diff)
downloadqtdeclarative-testsuites-e14a9ad9fefaf94454695e74db9873282ea22880.tar.gz
async-iteration: AsyncGeneratorPrototype tests (#1451)
Diffstat (limited to 'test/built-ins/AsyncGeneratorPrototype/next/iterator-result-prototype.js')
-rw-r--r--test/built-ins/AsyncGeneratorPrototype/next/iterator-result-prototype.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/built-ins/AsyncGeneratorPrototype/next/iterator-result-prototype.js b/test/built-ins/AsyncGeneratorPrototype/next/iterator-result-prototype.js
new file mode 100644
index 000000000..47b3ddd44
--- /dev/null
+++ b/test/built-ins/AsyncGeneratorPrototype/next/iterator-result-prototype.js
@@ -0,0 +1,46 @@
+// Copyright (C) 2018 Valerie Young. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-asyncgenerator-prototype-next
+description: >
+ "next" returns a promise for an IteratorResult object
+info: |
+ AsyncGenerator.prototype.next ( value )
+ 1. Let generator be the this value.
+ 2. Let completion be NormalCompletion(value).
+ 3. Return ! AsyncGeneratorEnqueue(generator, completion).
+
+ AsyncGeneratorEnqueue ( generator, completion )
+ ...
+ 4. Let queue be generator.[[AsyncGeneratorQueue]].
+ 5. Let request be AsyncGeneratorRequest{[[Completion]]: completion,
+ [[Capability]]: promiseCapability}.
+ 6. Append request to the end of queue.
+ ...
+
+ AsyncGeneratorResolve ( generator, value, done )
+ 1. Assert: generator is an AsyncGenerator instance.
+ 2. Let queue be generator.[[AsyncGeneratorQueue]].
+ 3. Assert: queue is not an empty List.
+ 4. Remove the first element from queue and let next be the value of that element.
+ 5. Let promiseCapability be next.[[Capability]].
+ 6. Let iteratorResult be ! CreateIterResultObject(value, done).
+ 7. Perform ! Call(promiseCapability.[[Resolve]], undefined, « iteratorResult »).
+ ...
+
+flags: [async]
+features: [async-iteration]
+---*/
+
+async function* g() {}
+
+g().next().then(function (result) {
+ assert(
+ Object.hasOwnProperty.call(result, 'value'), 'Has "own" property `value`'
+ );
+ assert(
+ Object.hasOwnProperty.call(result, 'done'), 'Has "own" property `done`'
+ );
+ assert.sameValue(Object.getPrototypeOf(result), Object.prototype);
+}).then($DONE, $DONE)