summaryrefslogtreecommitdiff
path: root/src/async-generators/yield-promise-reject-next-yield-star-sync-iterator.case
blob: 36fb4da678aa2486b02353fd03687994471dbe54 (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
// 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 * (async iterator) is treated as throw value
template: default
flags: [async]
---*/

//- setup
let error = new Error();
let iterable = [
  Promise.reject(error),
  "unreachable"
];
//- body
yield * iterable;
//- 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);