Debian Codegraph @

js/src/tests/test262/language/statements/class/static-init-sequence.js

raw
1 // Copyright (C) 2021 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-runtime-semantics-classelementevaluation
5 description: Static blocks are evaluated in the order they appear in the source text, interleaved with static fields
6 info: |
7 5.1.14 Runtime Semantics: ClassDefinitionEvaluation
8
9 [...]
10 34. For each element elementRecord of staticElements in List order, do
11 a. If elementRecord is a ClassFieldDefinition Record, then
12 i. Let status be the result of performing DefineField(F,
13 elementRecord).
14 b. Else,
15 i. Assert: fieldRecord is a ClassStaticBlockDefinition Record.
16 ii. Let status be the result of performing EvaluateStaticBlock(F,
17 elementRecord).
18 [...]
19 features: [class-static-fields-public, class-static-block]
20 ---*/
21
22 var sequence = [];
23
24 class C {
25 static x = sequence.push('first field');
26 static {
27 sequence.push('first block');
28 }
29 static x = sequence.push('second field');
30 static {
31 sequence.push('second block');
32 }
33 }
34
35 assert.sameValue(sequence[0], 'first field');
36 assert.sameValue(sequence[1], 'first block');
37 assert.sameValue(sequence[2], 'second field');
38 assert.sameValue(sequence[3], 'second block');
39
40 reportCompare(0, 0);