Debian Codegraph @

js/src/tests/test262/language/statements/class/static-init-abrupt.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-class-definitions-static-semantics-early-errors
5 description: Returns abrupt completion and halts further class body evaluation
6 info: |
7 34. For each element elementRecord of staticElements in List order, do
8 a. If elementRecord is a ClassFieldDefinition Record, then
9 [...]
10 b. Else,
11 i. Assert: fieldRecord is a ClassStaticBlockDefinition Record.
12 ii. Let status be the result of performing EvaluateStaticBlock(F,
13 elementRecord).
14 d. If status is an abrupt completion, then
15 i. Set the running execution context's LexicalEnvironment to lex.
16 ii. Set the running execution context's PrivateEnvironment to
17 outerPrivateEnvironment.
18 iii. Return Completion(status).
19 features: [class-static-fields-public, class-static-block]
20 ---*/
21
22 var thrown = new Test262Error();
23 var caught;
24 var sameBlock = false;
25 var subsequentField = false;
26 var subsequentBlock = false;
27
28 try {
29 class C {
30 static {
31 throw thrown;
32 sameBlock = true;
33 }
34 static x = subsequentField = true;
35 static {
36 subsequentBlock = true;
37 }
38 }
39 } catch (error) {
40 caught = error;
41 }
42
43 assert.sameValue(caught, thrown);
44 assert.sameValue(sameBlock, false, 'same block');
45 assert.sameValue(subsequentField, false, 'subsequent field');
46 assert.sameValue(subsequentBlock, false, 'subsequent block');
47
48 reportCompare(0, 0);