tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

async-gen-yield-promise-reject-next-yield-star-async-iterator.js (1340B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-promise-reject-next-yield-star-async-iterator.case
      4 // - src/async-generators/default/async-obj-method.template
      5 /*---
      6 description: yield * (async iterator) is treated as throw value (Async generator method)
      7 esid: prod-AsyncGeneratorMethod
      8 features: [async-iteration]
      9 flags: [generated, async]
     10 info: |
     11    Async Generator Function Definitions
     12 
     13    AsyncGeneratorMethod :
     14      async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
     15 
     16 ---*/
     17 let error = new Error();
     18 async function * readFile() {
     19  yield Promise.reject(error);
     20  yield "unreachable";
     21 }
     22 
     23 var callCount = 0;
     24 
     25 var gen = {
     26  async *method() {
     27    callCount += 1;
     28    yield * readFile();
     29 
     30  }
     31 }.method;
     32 
     33 var iter = gen();
     34 
     35 iter.next().then(() => {
     36  throw new Test262Error("Promise incorrectly resolved.");
     37 }, rejectValue => {
     38  // yield Promise.reject(error);
     39  assert.sameValue(rejectValue, error);
     40 
     41  iter.next().then(({done, value}) => {
     42    // iter is closed now.
     43    assert.sameValue(done, true, "The value of IteratorResult.done is `true`");
     44    assert.sameValue(value, undefined, "The value of IteratorResult.value is `undefined`");
     45  }).then($DONE, $DONE);
     46 }, $DONE).catch($DONE);
     47 
     48 assert.sameValue(callCount, 1);