Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/computed-name-toprimitive.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/class-elements/computed-name-toprimitive.case
3 // - src/class-elements/default/cls-decl.template
4 /*---
5 description: ToPrimitive evaluation in the ComputedPropertyName (field definitions in a class declaration)
6 esid: prod-FieldDefinition
7 features: [class-fields-public, computed-property-names, Symbol.toPrimitive, class]
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 class C {
65 [obj1] = 42;
66 [obj2] = 43;
67 [obj3] = 44;
68 }
69
70 var c = new C();
71
72 assert(
73 !Object.prototype.hasOwnProperty.call(C.prototype, "d"),
74 "d doesn't appear as an own property on C prototype"
75 );
76 assert(
77 !Object.prototype.hasOwnProperty.call(C, "d"),
78 "d doesn't appear as an own property on C constructor"
79 );
80
81 verifyProperty(c, "d", {
82 value: 42,
83 enumerable: true,
84 writable: true,
85 configurable: true
86 });
87
88 assert(
89 !Object.prototype.hasOwnProperty.call(C.prototype, "e"),
90 "e doesn't appear as an own property on C prototype"
91 );
92 assert(
93 !Object.prototype.hasOwnProperty.call(C, "e"),
94 "e doesn't appear as an own property on C constructor"
95 );
96
97 verifyProperty(c, "e", {
98 value: 43,
99 enumerable: true,
100 writable: true,
101 configurable: true
102 });
103
104 assert(
105 !Object.prototype.hasOwnProperty.call(C.prototype, "f"),
106 "f doesn't appear as an own property on C prototype"
107 );
108 assert(!
109 Object.prototype.hasOwnProperty.call(C, "f"),
110 "f doesn't appear as an own property on C constructor"
111 );
112
113 verifyProperty(c, "f", {
114 value: 44,
115 enumerable: true,
116 writable: true,
117 configurable: true
118 });
119
120 reportCompare(0, 0);