tor-browser

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

rhs-iter.js (1073B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-generator-function-definitions-runtime-semantics-evaluation
      5 es6id: 14.4.14
      6 description: >
      7  Iteration protocol is not initiated for non-delegating YieldExpression
      8 info: |
      9  YieldExpression:yieldAssignmentExpression
     10 
     11  1. Let exprRef be the result of evaluating AssignmentExpression.
     12  2. Let value be ? GetValue(exprRef).
     13  3. Return ? GeneratorYield(CreateIterResultObject(value, false)).
     14 features: [generators, Symbol.iterator]
     15 ---*/
     16 
     17 var callCount = 0;
     18 var iterSpy = Object.defineProperty({}, Symbol.iterator, {
     19  get: function() {
     20    callCount += 1;
     21  }
     22 });
     23 function* g() {
     24  yield iterSpy;
     25 }
     26 var iter = g();
     27 var result;
     28 
     29 result = iter.next();
     30 
     31 assert.sameValue(result.value, iterSpy);
     32 assert.sameValue(result.done, false);
     33 assert.sameValue(callCount, 0);
     34 
     35 result = iter.next();
     36 
     37 assert.sameValue(result.value, undefined);
     38 assert.sameValue(result.done, true);
     39 assert.sameValue(callCount, 0);
     40 
     41 reportCompare(0, 0);