tor-browser

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

star-rhs-iter-thrw-thrw-call-err.js (1448B)


      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 invoking iterator `throw` 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        [...]
     17     b. Else if received.[[Type]] is throw, then
     18        i. Let throw be ? GetMethod(iterator, "throw").
     19        ii. If throw is not undefined, then
     20            1. Let innerResult be ? Call(throw, iterator, « received.[[Value]]
     21               »).
     22 features: [generators, Symbol.iterator]
     23 ---*/
     24 
     25 var thrown = new Test262Error();
     26 var badIter = {};
     27 badIter[Symbol.iterator] = function() {
     28  return {
     29    next: function() {
     30      return { done: false };
     31    },
     32    throw: function() {
     33      throw thrown;
     34    }
     35  };
     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 iter.next();
     48 result = iter.throw();
     49 
     50 assert.sameValue(result.value, undefined);
     51 assert.sameValue(result.done, true);
     52 assert.sameValue(caught, thrown);
     53 
     54 reportCompare(0, 0);