Debian Codegraph @

js/src/tests/test262/language/expressions/class/elements/static-field-anonymous-function-length.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/class-elements/static-field-anonymous-function-length.case
3 // - src/class-elements/default/cls-expr.template
4 /*---
5 description: Anonymous function in field initilizer have length properly set (field definitions in a class expression)
6 esid: prod-FieldDefinition
7 features: [class-static-fields-private, class-static-fields-public, class]
8 flags: [generated]
9 info: |
10 Updated Productions
11
12 ClassElement :
13 ...
14 static FieldDefinition ;
15
16 FieldDefinition :
17 ClassElementName Initializer_opt
18
19 ClassDefinitionEvaluation:
20 ...
21
22 27. Let staticFields be a new empty List.
23 28. For each ClassElement e in order from elements,
24 a. If IsStatic of e is false, then
25 ...
26 b. Else,
27 i. Let field be the result of performing PropertyDefinitionEvaluation for m ClassElementEvaluation for e with arguments F and false.
28 c. If field is an abrupt completion, then
29 ...
30 d. If field is not empty,
31 i. If IsStatic of e is false, append field to instanceFields.
32 ii. Otherwise, append field to staticFields.
33
34 34. For each item fieldRecord in order from staticFields,
35 a. Perform ? DefineField(F, field).
36 ...
37
38 DefineField(receiver, fieldRecord)
39 1. Assert: Type(receiver) is Object.
40 2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation.
41 3. Let name be fieldRecord.[[Name]].
42 4. Let initializer be fieldRecord.[[Initializer]].
43 5. If initializer is not empty, then
44 a. Let initValue be ? Call(initializer, receiver).
45 ...
46
47 ---*/
48
49
50 var C = class {
51 static #field = (a, b) => undefined;
52 static field = function() {};
53
54 static accessPrivateField() {
55 return this.#field;
56 }
57
58 }
59
60 assert.sameValue(C.accessPrivateField().length, 2);
61 assert.sameValue(C.field.length, 0);
62
63 reportCompare(0, 0);