tor-browser

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

star-rhs-iter-nrml-next-get-err.js (1388B)


      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: Abrupt completion returned when accessing 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 features: [generators, Symbol.iterator]
     25 ---*/
     26 
     27 var thrown = new Test262Error();
     28 var badIter = {};
     29 var poisonedNext = Object.defineProperty({}, 'next', {
     30  get: function() {
     31    throw thrown;
     32  }
     33 });
     34 badIter[Symbol.iterator] = function() {
     35  return poisonedNext;
     36 };
     37 function* g() {
     38  try {
     39    yield * badIter;
     40  } catch (err) {
     41    caught = err;
     42  }
     43 }
     44 var iter = g();
     45 var result, caught;
     46 
     47 result = iter.next();
     48 
     49 assert.sameValue(result.value, undefined);
     50 assert.sameValue(result.done, true);
     51 assert.sameValue(caught, thrown);
     52 
     53 reportCompare(0, 0);