tor-browser

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

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


      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-method.template
      5 /*---
      6 description: Use yield value in a array spread position (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    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 { async *gen() {
     35    callCount += 1;
     36    yield [...yield];
     37 }}
     38 
     39 var gen = C.prototype.gen;
     40 
     41 var iter = gen();
     42 
     43 iter.next(false);
     44 var item = iter.next(arr);
     45 
     46 item.then(({ done, value }) => {
     47  assert.notSameValue(value, arr, 'value is a new array');
     48  assert(Array.isArray(value), 'value is an Array exotic object');
     49  assert.sameValue(value.length, 3)
     50  assert.sameValue(value[0], 'a');
     51  assert.sameValue(value[1], 'b');
     52  assert.sameValue(value[2], 'c');
     53  assert.sameValue(done, false);
     54 }).then($DONE, $DONE);
     55 
     56 assert.sameValue(callCount, 1);