Debian Codegraph @

js/src/tests/test262/language/statements/try/dstr/obj-ptrn-id-init-fn-name-class.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case
3 // - src/dstr-binding/default/try.template
4 /*---
5 description: SingleNameBinding assigns `name` to "anonymous" classes (try statement)
6 esid: sec-runtime-semantics-catchclauseevaluation
7 features: [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.7 Runtime Semantics: KeyedBindingInitialization
18
19 SingleNameBinding : BindingIdentifier Initializeropt
20
21 [...]
22 6. If Initializer is present and v is undefined, then
23 [...]
24 d. If IsAnonymousFunctionDefinition(Initializer) is true, then
25 i. Let hasNameProperty be HasOwnProperty(v, "name").
26 ii. ReturnIfAbrupt(hasNameProperty).
27 iii. If hasNameProperty is false, perform SetFunctionName(v,
28 bindingId).
29 ---*/
30
31 var ranCatch = false;
32
33 try {
34 throw {};
35 } catch ({ cls = class {}, xCls = class X {}, xCls2 = class { static name() {} } }) {
36 assert.sameValue(cls.name, 'cls');
37 assert.notSameValue(xCls.name, 'xCls');
38 assert.notSameValue(xCls2.name, 'xCls2');
39 ranCatch = true;
40 }
41
42 assert(ranCatch, 'executed `catch` block');
43
44 reportCompare(0, 0);