Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/fields-computed-name-toprimitive.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/class-fields/computed-name-toprimitive.case
3 // - src/class-fields/default/cls-expr.template
4 /*---
5 description: ToPrimitive evaluation in the ComputedPropertyName (field definitions in a class expression)
6 esid: prod-FieldDefinition
7 features: [computed-property-names, Symbol.toPrimitive, class, class-fields-public]
8 flags: [generated]
9 includes: [propertyHelper.js]
10 info: |
11 Runtime Semantics: ClassDefinitionEvaluation
12
13 ...
14 27. For each ClassElement e in order from elements
15 a. If IsStatic of me is false, then
16 i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
17 b. Else,
18 i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
19 c. If fields is an abrupt completion, then
20 i. Set the running execution context's LexicalEnvironment to lex.
21 ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
22 iii. Return Completion(status).
23 ...
24
25 Runtime Semantics: ClassElementEvaluation
26
27 ClassElement: FieldDefinition;
28 Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
29
30 Runtime Semantics: ClassFieldDefinitionEvaluation
31 With parameters isStatic and homeObject.
32
33 1. Let fieldName be the result of evaluating ClassElementName.
34 2. ReturnIfAbrupt(fieldName).
35 ...
36
37 Runtime Semantics: Evaluation
38 ComputedPropertyName: [ AssignmentExpression ]
39
40 1. Let exprValue be the result of evaluating AssignmentExpression.
41 2. Let propName be ? GetValue(exprValue).
42 3. Return ? ToPropertyKey(propName).
43
44 ---*/
45 var err = function() { throw new Test262Error(); };
46 var obj1 = {
47 [Symbol.toPrimitive]: function() { return "d"; },
48 toString: err,
49 valueOf: err
50 };
51
52 var obj2 = {
53 toString: function() { return "e"; },
54 valueOf: err
55 };
56
57 var obj3 = {
58 toString: undefined,
59 valueOf: function() { return "f"; }
60 };
61
62
63
64 var C = class {
65 [obj1] = 42;
66 [obj2] = 43;
67 [obj3] = 44;
68 }
69
70 var c = new C();
71
72 assert.sameValue(Object.hasOwnProperty.call(C.prototype, "d"), false);
73 assert.sameValue(Object.hasOwnProperty.call(C, "d"), false);
74
75 verifyProperty(c, "d", {
76 value: 42,
77 enumerable: true,
78 writable: true,
79 configurable: true
80 });
81
82 assert.sameValue(Object.hasOwnProperty.call(C.prototype, "e"), false);
83 assert.sameValue(Object.hasOwnProperty.call(C, "e"), false);
84
85 verifyProperty(c, "e", {
86 value: 43,
87 enumerable: true,
88 writable: true,
89 configurable: true
90 });
91
92 assert.sameValue(Object.hasOwnProperty.call(C.prototype, "f"), false);
93 assert.sameValue(Object.hasOwnProperty.call(C, "f"), false);
94
95 verifyProperty(c, "f", {
96 value: 44,
97 enumerable: true,
98 writable: true,
99 configurable: true
100 });