tor-browser

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

yield-promise-reject-next-yield-star-sync-iterator.js (1446B)


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