tor-browser

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

yield-star-next-not-callable-symbol-throw.js (2778B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-star-next-not-callable-symbol-throw.case
      4 // - src/async-generators/default/async-class-decl-private-method.template
      5 /*---
      6 description: Not-callable next value in a yield star position - symbol (Async Generator method as a ClassDeclaration element)
      7 esid: prod-AsyncGeneratorPrivateMethod
      8 features: [Symbol.iterator, Symbol.asyncIterator, async-iteration, class-methods-private]
      9 flags: [generated, async]
     10 info: |
     11    ClassElement :
     12      PrivateMethodDefinition
     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    YieldExpression: yield * AssignmentExpression
     24    ...
     25    6. Repeat
     26      a. If received.[[Type]] is normal, then
     27        ii. Let innerResult be ? Invoke(iterator, "next",
     28            « received.[[Value]] »).
     29    ...
     30 
     31 ---*/
     32 var obj = {
     33  get [Symbol.iterator]() {
     34    throw new Test262Error('it should not get Symbol.iterator');
     35  },
     36  [Symbol.asyncIterator]() {
     37    return {
     38      next: Symbol('oi')
     39    };
     40  }
     41 };
     42 
     43 
     44 
     45 var callCount = 0;
     46 
     47 class C {
     48    async *#gen() {
     49        callCount += 1;
     50        yield* obj;
     51          throw new Test262Error('abrupt completion closes iter');
     52 
     53    }
     54    get gen() { return this.#gen; }
     55 }
     56 
     57 const c = new C();
     58 
     59 // Test the private fields do not appear as properties before set to value
     60 assert(
     61  !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
     62  "#gen does not appear as an own property on C prototype"
     63 );
     64 assert(
     65  !Object.prototype.hasOwnProperty.call(C, "#gen"),
     66  "#gen does not appear as an own property on C constructor"
     67 );
     68 assert(
     69  !Object.prototype.hasOwnProperty.call(c, "#gen"),
     70  "#gen does not appear as an own property on C instance"
     71 );
     72 
     73 var iter = c.gen();
     74 
     75 iter.next().then(() => {
     76  throw new Test262Error('Promise incorrectly fulfilled.');
     77 }, v => {
     78  assert.sameValue(v.constructor, TypeError, "TypeError");
     79 
     80  iter.next().then(({ done, value }) => {
     81    assert.sameValue(done, true, 'the iterator is completed');
     82    assert.sameValue(value, undefined, 'value is undefined');
     83  }).then($DONE, $DONE);
     84 }).catch($DONE);
     85 
     86 assert.sameValue(callCount, 1);
     87 
     88 // Test the private fields do not appear as properties after set to value
     89 assert(
     90  !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
     91  "#gen does not appear as an own property on C prototype"
     92 );
     93 assert(
     94  !Object.prototype.hasOwnProperty.call(C, "#gen"),
     95  "#gen does not appear as an own property on C constructor"
     96 );
     97 assert(
     98  !Object.prototype.hasOwnProperty.call(c, "#gen"),
     99  "#gen does not appear as an own property on C instance"
    100 );