tor-browser

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

yield-spread-arr-single.js (2401B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-spread-arr-single.case
      4 // - src/async-generators/default/async-class-decl-private-method.template
      5 /*---
      6 description: Use yield value in a array spread position (Async Generator method as a ClassDeclaration element)
      7 esid: prod-AsyncGeneratorPrivateMethod
      8 features: [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    Array Initializer
     24 
     25    SpreadElement[Yield, Await]:
     26      ...AssignmentExpression[+In, ?Yield, ?Await]
     27 
     28 ---*/
     29 var arr = ['a', 'b', 'c'];
     30 
     31 
     32 var callCount = 0;
     33 
     34 class C {
     35    async *#gen() {
     36        callCount += 1;
     37        yield [...yield];
     38    }
     39    get gen() { return this.#gen; }
     40 }
     41 
     42 const c = new C();
     43 
     44 // Test the private fields do not appear as properties before set to value
     45 assert(
     46  !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
     47  "#gen does not appear as an own property on C prototype"
     48 );
     49 assert(
     50  !Object.prototype.hasOwnProperty.call(C, "#gen"),
     51  "#gen does not appear as an own property on C constructor"
     52 );
     53 assert(
     54  !Object.prototype.hasOwnProperty.call(c, "#gen"),
     55  "#gen does not appear as an own property on C instance"
     56 );
     57 
     58 var iter = c.gen();
     59 
     60 iter.next(false);
     61 var item = iter.next(arr);
     62 
     63 item.then(({ done, value }) => {
     64  assert.notSameValue(value, arr, 'value is a new array');
     65  assert(Array.isArray(value), 'value is an Array exotic object');
     66  assert.sameValue(value.length, 3)
     67  assert.sameValue(value[0], 'a');
     68  assert.sameValue(value[1], 'b');
     69  assert.sameValue(value[2], 'c');
     70  assert.sameValue(done, false);
     71 }).then($DONE, $DONE);
     72 
     73 assert.sameValue(callCount, 1);
     74 
     75 // Test the private fields do not appear as properties after set to value
     76 assert(
     77  !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
     78  "#gen does not appear as an own property on C prototype"
     79 );
     80 assert(
     81  !Object.prototype.hasOwnProperty.call(C, "#gen"),
     82  "#gen does not appear as an own property on C constructor"
     83 );
     84 assert(
     85  !Object.prototype.hasOwnProperty.call(c, "#gen"),
     86  "#gen does not appear as an own property on C instance"
     87 );