summaryrefslogtreecommitdiff
path: root/src/async-generators/yield-promise-reject-next-for-await-of-async-iterator.case
blob: bca3550a4496a91c3e3f1486811d9179815011d0 (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
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
desc: yield * [Promise.reject(value)] is treated as throw value
template: default
flags: [async]
---*/

//- setup
let error = new Error();
async function * readFile() {
  yield Promise.reject(error);
  yield "unreachable";
}
//- body
for await (let line of readFile()) {
  yield line;
}
//- assertions
iter.next().then(() => {
  throw new Test262Error("Promise incorrectly resolved.");
}, rejectValue => {

  // yield Promise.reject(error);
  assert.sameValue(rejectValue, error);

  iter.next().then(({done, value}) => {
    // iter is closed now.
    assert.sameValue(done, true, "The value of IteratorResult.done is `true`");
    assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`");
  }).then($DONE, $DONE);
}).catch($DONE);