tor-browser

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

yield-as-generator-method-binding-identifier.js (833B)


      1 // Copyright (C) 2013 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    `yield` is a valid BindingIdentifier for GeneratorMethods
      7 features: [generators]
      8 es6id: 12.1.1
      9 ---*/
     10 
     11 var iter, result;
     12 var obj = {
     13  *yield() { (yield 3) + (yield 4); }
     14 }
     15 
     16 iter = obj.yield();
     17 
     18 result = iter.next();
     19 assert.sameValue(result.value, 3, 'First result `value`');
     20 assert.sameValue(result.done, false, 'First result `done` flag');
     21 
     22 result = iter.next();
     23 assert.sameValue(result.value, 4, 'Second result `value`');
     24 assert.sameValue(result.done, false, 'Second result `done` flag');
     25 
     26 result = iter.next();
     27 assert.sameValue(result.value, undefined, 'Third result `value`');
     28 assert.sameValue(result.done, true, 'Third result `done` flag');;
     29 
     30 reportCompare(0, 0);