tor-browser

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

star-rhs-iter-nrml-next-invoke.js (1384B)


      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: Invocation of iterator `next` method
      7 info: |
      8  YieldExpression : yield * AssignmentExpression
      9 
     10  1. Let exprRef be the result of evaluating AssignmentExpression.
     11  2. Let value be ? GetValue(exprRef).
     12  3. Let iterator be ? GetIterator(value).
     13  4. Let received be NormalCompletion(undefined).
     14  5. Repeat
     15     a. If received.[[Type]] is normal, then
     16        i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]).
     17 
     18  7.4.2 IteratorNext
     19 
     20  1. If value was not passed, then
     21     [...]
     22  2. Else,
     23     a. Let result be ? Invoke(iterator, "next", « value »).
     24     [...]
     25 features: [generators, Symbol.iterator]
     26 ---*/
     27 
     28 var args, thisValue;
     29 var callCount = 0;
     30 var spyIterator = {
     31  next: function() {
     32    callCount += 1;
     33    args = arguments;
     34    thisValue = this;
     35    return { done: true };
     36  }
     37 };
     38 var spyIterable = {};
     39 spyIterable[Symbol.iterator] = function() {
     40  return spyIterator;
     41 };
     42 function* g() {
     43  yield * spyIterable;
     44 }
     45 var iter = g();
     46 
     47 iter.next(9876);
     48 
     49 assert.sameValue(callCount, 1);
     50 assert.sameValue(args.length, 1);
     51 assert.sameValue(args[0], undefined);
     52 assert.sameValue(thisValue, spyIterator);
     53 
     54 reportCompare(0, 0);