tor-browser

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

generator-prop-name-yield-expr.js (874B)


      1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: >
      6    When the `yield` keyword occurs within the PropertyName of a
      7    GeneratorMethod within a generator function, it behaves as a
      8    YieldExpression.
      9 es6id: 14.4
     10 features: [generators]
     11 flags: [noStrict]
     12 ---*/
     13 
     14 var obj = null;
     15 var yield = 'propNameViaIdentifier';
     16 var iter = (function*() {
     17  obj = {
     18    *[yield]() {}
     19  };
     20 })();
     21 
     22 iter.next();
     23 
     24 assert.sameValue(obj, null);
     25 
     26 iter.next('propNameViaExpression');
     27 
     28 assert(
     29  !Object.prototype.hasOwnProperty.call(obj, 'propNameViaIdentifier'),
     30  "The property name is not taken from the 'yield' variable"
     31 );
     32 assert(
     33  Object.prototype.hasOwnProperty.call(obj, 'propNameViaExpression'),
     34  "The property name is taken from the yield expression"
     35 );
     36 
     37 reportCompare(0, 0);