tor-browser

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

star-rhs-iter-get-call-non-obj.js (1196B)


      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: TypeError thrown when @@iterator method returns a non-object value
      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 
     14  7.4.1 GetIterator
     15 
     16  1. If method was not passed, then
     17     a. Let method be ? GetMethod(obj, @@iterator).
     18  2. Let iterator be ? Call(method, obj).
     19  3. If Type(iterator) is not Object, throw a TypeError exception.
     20 features: [generators, Symbol.iterator]
     21 ---*/
     22 
     23 var badIter = {};
     24 badIter[Symbol.iterator] = function() {
     25  return 7;
     26 };
     27 function* g() {
     28  try {
     29    yield * badIter;
     30  } catch (err) {
     31    caught = err;
     32  }
     33 }
     34 var iter = g();
     35 var result, caught;
     36 
     37 result = iter.next();
     38 
     39 assert.sameValue(result.value, undefined);
     40 assert.sameValue(result.done, true);
     41 assert.sameValue(typeof caught, 'object');
     42 assert.sameValue(caught.constructor, TypeError);
     43 
     44 reportCompare(0, 0);