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