Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/async-generator/expression-yield-as-statement.js

raw
1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 author: Caitlin Potter <[email protected]>
6 esid: sec-generator-function-definitions
7 description: >
8 `yield` is a valid statement within async generator function bodies.
9 flags: [async]
10 features: [async-iteration]
11 ---*/
12
13 var g1 = async function*() { yield; };
14 var g2 = async function*() { yield 1; };
15
16 var iter1 = g1();
17 iter1.next().then(function(result) {
18 assert.sameValue(
19 result.value, undefined, "Without right-hand-side: first result `value`");
20 assert.sameValue(
21 result.done, false, "Without right-hand-side: first result `done` flag");
22 }).then(undefined, $DONE);
23 iter1.next().then(function(result) {
24 assert.sameValue(
25 result.value, undefined, "Without right-hand-side: second result `value`");
26 assert.sameValue(
27 result.done, true, "Without right-hand-side: second result `done` flag");
28 }).then(undefined, $DONE);
29
30 var iter2 = g2();
31 iter2.next().then(function(result) {
32 assert.sameValue(
33 result.value, 1, "With right-hand-side: first result `value`");
34 assert.sameValue(
35 result.done, false, "With right-hand-side: first result `done` flag");
36 }).then(undefined, $DONE);
37 iter2.next().then(function(result) {
38 assert.sameValue(
39 result.value, undefined, "With right-hand-side: second result `value`");
40 assert.sameValue(
41 result.done, true, "With right-hand-side: second result `done` flag");
42 }).then($DONE, $DONE);