tor-browser

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

named-yield-identifier-non-strict.js (1024B)


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