Debian Codegraph @

js/src/tests/test262/language/statements/try/dstr/ary-ptrn-elem-ary-elision-init.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case
3 // - src/dstr-binding/default/try.template
4 /*---
5 description: BindingElement with array binding pattern and initializer is used (try statement)
6 esid: sec-runtime-semantics-catchclauseevaluation
7 features: [generators, destructuring-binding]
8 flags: [generated]
9 info: |
10 Catch : catch ( CatchParameter ) Block
11
12 [...]
13 5. Let status be the result of performing BindingInitialization for
14 CatchParameter passing thrownValue and catchEnv as arguments.
15 [...]
16
17 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
18
19 BindingElement : BindingPatternInitializer opt
20
21 [...]
22 2. If iteratorRecord.[[done]] is true, let v be undefined.
23 3. If Initializer is present and v is undefined, then
24 a. Let defaultValue be the result of evaluating Initializer.
25 b. Let v be ? GetValue(defaultValue).
26 4. Return the result of performing BindingInitialization of BindingPattern
27 with v and environment as the arguments.
28
29 ---*/
30 var first = 0;
31 var second = 0;
32 function* g() {
33 first += 1;
34 yield;
35 second += 1;
36 };
37
38 var ranCatch = false;
39
40 try {
41 throw [];
42 } catch ([[,] = g()]) {
43 assert.sameValue(first, 1);
44 assert.sameValue(second, 0);
45 ranCatch = true;
46 }
47
48 assert(ranCatch, 'executed `catch` block');
49
50 reportCompare(0, 0);