js/src/tests/test262/language/expressions/object/dstr/gen-meth-ary-ptrn-rest-id-iter-step-err.js
raw symbols SCIP| 1 | // This file was procedurally generated from the following sources: |
| 2 | // - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case |
| 3 | // - src/dstr-binding/error/gen-meth.template |
| 4 | /*--- |
| 5 | description: Error forwarding when IteratorStep returns an abrupt completion (generator method) |
| 6 | esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation |
| 7 | features: [generators, destructuring-binding] |
| 8 | flags: [generated] |
| 9 | info: | |
| 10 | GeneratorMethod : |
| 11 | * PropertyName ( StrictFormalParameters ) { GeneratorBody } |
| 12 | |
| 13 | 1. Let propKey be the result of evaluating PropertyName. |
| 14 | 2. ReturnIfAbrupt(propKey). |
| 15 | 3. If the function code for this GeneratorMethod is strict mode code, |
| 16 | let strict be true. Otherwise let strict be false. |
| 17 | 4. Let scope be the running execution context's LexicalEnvironment. |
| 18 | 5. Let closure be GeneratorFunctionCreate(Method, |
| 19 | StrictFormalParameters, GeneratorBody, scope, strict). |
| 20 | [...] |
| 21 | |
| 22 | 9.2.1 [[Call]] ( thisArgument, argumentsList) |
| 23 | |
| 24 | [...] |
| 25 | 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). |
| 26 | [...] |
| 27 | |
| 28 | 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) |
| 29 | |
| 30 | 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). |
| 31 | [...] |
| 32 | |
| 33 | 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) |
| 34 | |
| 35 | [...] |
| 36 | 23. Let iteratorRecord be Record {[[iterator]]: |
| 37 | CreateListIterator(argumentsList), [[done]]: false}. |
| 38 | 24. If hasDuplicates is true, then |
| 39 | [...] |
| 40 | 25. Else, |
| 41 | b. Let formalStatus be IteratorBindingInitialization for formals with |
| 42 | iteratorRecord and env as arguments. |
| 43 | [...] |
| 44 | |
| 45 | 13.3.3.6 Runtime Semantics: IteratorBindingInitialization |
| 46 | BindingRestElement : ... BindingIdentifier |
| 47 | 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, |
| 48 | environment). |
| 49 | 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, |
| 50 | a. If iteratorRecord.[[done]] is false, |
| 51 | i. Let next be IteratorStep(iteratorRecord.[[iterator]]). |
| 52 | ii. If next is an abrupt completion, set iteratorRecord.[[done]] to |
| 53 | true. |
| 54 | iii. ReturnIfAbrupt(next). |
| 55 | |
| 56 | ---*/ |
| 57 | var first = 0; |
| 58 | var second = 0; |
| 59 | var iter = function*() { |
| 60 | first += 1; |
| 61 | throw new Test262Error(); |
| 62 | second += 1; |
| 63 | }(); |
| 64 | |
| 65 | var obj = { |
| 66 | *method([...x]) {} |
| 67 | }; |
| 68 | |
| 69 | assert.throws(Test262Error, function() { |
| 70 | obj.method(iter); |
| 71 | }); |
| 72 | |
| 73 | iter.next(); |
| 74 | assert.sameValue(first, 1); |
| 75 | assert.sameValue(second, 0, 'Iterator is closed following abrupt completion.'); |
| 76 | |
| 77 | reportCompare(0, 0); |