star-rhs-iter-nrml-res-done-err.js (1406B)
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: > 7 Abrupt completion returned when accessing `done` property of iteration result 8 info: | 9 YieldExpression : yield * AssignmentExpression 10 11 1. Let exprRef be the result of evaluating AssignmentExpression. 12 2. Let value be ? GetValue(exprRef). 13 3. Let iterator be ? GetIterator(value). 14 4. Let received be NormalCompletion(undefined). 15 5. Repeat 16 a. If received.[[Type]] is normal, then 17 i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). 18 ii. Let done be ? IteratorComplete(innerResult). 19 20 7.4.3 IteratorComplete 21 22 1. Assert: Type(iterResult) is Object. 23 2. Return ToBoolean(? Get(iterResult, "done")). 24 features: [generators, Symbol.iterator] 25 ---*/ 26 27 var thrown = new Test262Error(); 28 var badIter = {}; 29 var poisonedDone = Object.defineProperty({}, 'done', { 30 get: function() { 31 throw thrown; 32 } 33 }); 34 badIter[Symbol.iterator] = function() { 35 return { 36 next: function() { 37 return poisonedDone; 38 } 39 }; 40 }; 41 function* g() { 42 try { 43 yield * badIter; 44 } catch (err) { 45 caught = err; 46 } 47 } 48 var iter = g(); 49 var result, caught; 50 51 result = iter.next(); 52 53 assert.sameValue(caught, thrown); 54 55 reportCompare(0, 0);