tests/auto/qml/ecmascripttests/test262/test/language/expressions/yield/star-rhs-iter-nrml-next-call-err.js
raw symbols SCIP| 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 `next` 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 | i. Let innerResult be ? IteratorNext(iterator, received.[[Value]]). |
| 17 | |
| 18 | 7.4.2 IteratorNext |
| 19 | |
| 20 | 1. If value was not passed, then |
| 21 | [...] |
| 22 | 2. Else, |
| 23 | a. Let result be ? Invoke(iterator, "next", « value »). |
| 24 | features: [generators, Symbol.iterator] |
| 25 | ---*/ |
| 26 | |
| 27 | var thrown = new Test262Error(); |
| 28 | var badIter = {}; |
| 29 | badIter[Symbol.iterator] = function() { |
| 30 | return { |
| 31 | next: function() { |
| 32 | throw thrown; |
| 33 | } |
| 34 | }; |
| 35 | }; |
| 36 | function* g() { |
| 37 | try { |
| 38 | yield * badIter; |
| 39 | } catch (err) { |
| 40 | caught = err; |
| 41 | } |
| 42 | } |
| 43 | var iter = g(); |
| 44 | var result, caught; |
| 45 | |
| 46 | result = iter.next(); |
| 47 | |
| 48 | assert.sameValue(result.value, undefined); |
| 49 | assert.sameValue(result.done, true); |
| 50 | assert.sameValue(caught, thrown); |