Debian Codegraph @

js/src/tests/test262/language/expressions/async-generator/expression-yield-as-statement.js

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