summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/async-generator/yield-star-promise-not-unwrapped.js
blob: 4dabe6af43bfe048e2470ead6c1a6d1a5288288a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// |reftest| async
// Copyright (C) 2022 Kevin Gibbons. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-generator-function-definitions-runtime-semantics-evaluation
description: >
  `yield*` in an async generator does not await promises returned by a manually implemented async iterator.
flags: [async]
features: [async-iteration]
---*/

var innerPromise = Promise.resolve("unwrapped value");

var asyncIter = {
  [Symbol.asyncIterator]() {
    return this;
  },
  next() {
    return {
      done: false,
      value: innerPromise,
    };
  },
  get return() {
    throw new Test262Error(".return should not be accessed");
  },
  get throw() {
    throw new Test262Error(".throw should not be accessed");
  },
};

async function* f() {
  yield* asyncIter;
}

f()
  .next()
  .then(v => {
    assert.sameValue(v.value, innerPromise, "yield* should not unwrap promises from manually-implemented async iterators");
  })
  .then($DONE, $DONE)