star-rhs-iter-get-call-err.js (1229B)
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 the @@iterator 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 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 features: [generators, Symbol.iterator] 20 ---*/ 21 22 var thrown = new Test262Error(); 23 var badIter = {}; 24 badIter[Symbol.iterator] = function() { 25 throw thrown; 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 assert.sameValue(caught, undefined, 'method is not invoked eagerly'); 38 39 result = iter.next(); 40 41 assert.sameValue(result.value, undefined, 'iteration value'); 42 assert.sameValue(result.done, true, 'iteration status'); 43 assert.sameValue(caught, thrown, 'error value'); 44 45 reportCompare(0, 0);