intercalated-static-non-static-computed-fields.js (2447B)
1 // This file was procedurally generated from the following sources: 2 // - src/class-elements/intercalated-static-non-static-computed-fields.case 3 // - src/class-elements/default/cls-expr.template 4 /*--- 5 description: Computed class fields are executed in the order they are delcared, regardless it is static or instance field (field definitions in a class expression) 6 esid: prod-FieldDefinition 7 features: [class-static-fields-public, class-fields-public, class] 8 flags: [generated] 9 includes: [propertyHelper.js] 10 info: | 11 ClassTail : ClassHeritage { ClassBody } 12 ... 13 28. For each ClassElement e in order from elements, 14 a. If IsStatic of e is false, then 15 i. Let field be the result of performing ClassElementEvaluation for e with arguments proto and false. 16 b. Else, 17 i. Let field be the result of performing PropertyDefinitionEvaluation for mClassElementEvaluation for e with arguments F and false. 18 c. If field is an abrupt completion, then 19 ... 20 d. If field is not empty, 21 i. If IsStatic of e is false, append field to instanceFields. 22 ii. Otherwise, append field to staticFields. 23 ... 24 34. For each item fieldRecord in order from staticFields, 25 a. Perform ? DefineField(F, field). 26 ... 27 28 [[Construct]] (argumentsList, newTarget) 29 ... 30 8. If kind is "base", then 31 a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). 32 b. Let result be InitializeInstanceFields(thisArgument, F). 33 c. If result is an abrupt completion, then 34 i. Remove calleeContext from execution context stack and restore callerContext as the running execution context. 35 ii. Return Completion(result). 36 37 ---*/ 38 39 let i = 0; 40 41 42 var C = class { 43 [i++] = i++; 44 static [i++] = i++; 45 [i++] = i++; 46 } 47 48 let c = new C(); 49 50 // It is important to notice that static field initializer will run before any instance initializer 51 verifyProperty(c, "0", { 52 value: 4, 53 enumerable: true, 54 writable: true, 55 configurable: true 56 }); 57 58 verifyProperty(c, "2", { 59 value: 5, 60 enumerable: true, 61 writable: true, 62 configurable: true 63 }); 64 65 verifyProperty(C, "1", { 66 value: 3, 67 enumerable: true, 68 writable: true, 69 configurable: true 70 }); 71 72 assert.sameValue(i, 6); 73 assert.sameValue(c.hasOwnProperty('1'), false); 74 assert.sameValue(C.hasOwnProperty('0'), false); 75 assert.sameValue(C.hasOwnProperty('2'), false); 76 77 78 reportCompare(0, 0);