Debian Codegraph @

js/src/tests/test262/language/statements/for-await-of/async-func-decl-dstr-obj-id-init-fn-name-class.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/dstr-assignment-for-await/obj-id-init-fn-name-class.case
4 // - src/dstr-assignment-for-await/default/async-func-decl.template
5 /*---
6 description: Assignment of function `name` attribute (ClassExpression) (for-await-of statement in an async function declaration)
7 esid: sec-for-in-and-for-of-statements-runtime-semantics-labelledevaluation
8 features: [class, destructuring-binding, async-iteration]
9 flags: [generated, async]
10 includes: [propertyHelper.js]
11 info: |
12 IterationStatement :
13 for await ( LeftHandSideExpression of AssignmentExpression ) Statement
14
15 1. Let keyResult be the result of performing ? ForIn/OfHeadEvaluation(« »,
16 AssignmentExpression, iterate).
17 2. Return ? ForIn/OfBodyEvaluation(LeftHandSideExpression, Statement,
18 keyResult, assignment, labelSet).
19
20 13.7.5.13 Runtime Semantics: ForIn/OfBodyEvaluation
21
22 [...]
23 5. If destructuring is true and if lhsKind is assignment, then
24 a. Assert: lhs is a LeftHandSideExpression.
25 b. Let assignmentPattern be the parse of the source text corresponding to
26 lhs using AssignmentPattern as the goal symbol.
27 [...]
28
29 AssignmentProperty : IdentifierReference Initializeropt
30 [...] 6. If Initializeropt is present and v is undefined, then
31 [...]
32 d. If IsAnonymousFunctionDefinition(Initializer) is true, then
33 i. Let hasNameProperty be HasOwnProperty(v, "name").
34 ii. ReturnIfAbrupt(hasNameProperty).
35 iii. If hasNameProperty is false, perform SetFunctionName(v, P).
36
37 ---*/
38 let xCls, cls, xCls2;
39
40 let iterCount = 0;
41 async function fn() {
42 for await ({ xCls = class x {}, cls = class {}, xCls2 = class { static name() {} } } of [{}]) {
43 assert.notSameValue(xCls.name, 'xCls');
44 assert.notSameValue(xCls2.name, 'xCls2');
45
46 verifyProperty(cls, 'name', {
47 enumerable: false,
48 writable: false,
49 configurable: true,
50 value: 'cls'
51 });
52
53 iterCount += 1;
54 }
55 }
56
57 let promise = fn();
58
59 promise
60 .then(() => assert.sameValue(iterCount, 1, 'iteration occurred as expected'), $DONE)
61 .then($DONE, $DONE);