tor-browser

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

yield-identifier-non-strict.js (1188B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/async-generators/yield-identifier-non-strict.case
      4 // - src/async-generators/non-strict/async-declaration.template
      5 /*---
      6 description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Async generator function declaration - valid for non-strict only cases)
      7 esid: prod-AsyncGeneratorDeclaration
      8 features: [async-iteration]
      9 flags: [generated, noStrict, async]
     10 info: |
     11    Async Generator Function Definitions
     12 
     13    AsyncGeneratorDeclaration:
     14      async [no LineTerminator here] function * BindingIdentifier ( FormalParameters ) {
     15        AsyncGeneratorBody }
     16 
     17 ---*/
     18 
     19 
     20 var callCount = 0;
     21 
     22 async function *gen() {
     23  callCount += 1;
     24  return (function(arg) {
     25      var yield = arg + 1;
     26      return yield;
     27    }(yield))
     28 }
     29 
     30 var iter = gen();
     31 
     32 var item = iter.next();
     33 
     34 item.then(({ done, value }) => {
     35  assert.sameValue(done, false);
     36  assert.sameValue(value, undefined);
     37 });
     38 
     39 item = iter.next(42);
     40 
     41 item.then(({ done, value }) => {
     42  assert.sameValue(done, true);
     43  assert.sameValue(value, 43);
     44 }).then($DONE, $DONE);
     45 
     46 assert.sameValue(callCount, 1);