star-rhs-iter-get-get-err.js (1231B)
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 the @@iterator property 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 features: [generators, Symbol.iterator] 19 ---*/ 20 21 var thrown = new Test262Error(); 22 var poisonedIter = Object.defineProperty({}, Symbol.iterator, { 23 get: function() { 24 throw thrown; 25 } 26 }); 27 function* g() { 28 try { 29 yield * poisonedIter; 30 } catch (err) { 31 caught = err; 32 } 33 } 34 var iter = g(); 35 var result, caught; 36 37 assert.sameValue(caught, undefined, 'property is not accessed 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);