| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/class-fields/computed-name-toprimitive-symbol.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, Symbol, 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 s1 = Symbol(); |
| 46 |
var s2 = Symbol(); |
| 47 |
var s3 = Symbol(); |
| 48 |
var err = function() { throw new Test262Error(); }; |
| 49 |
var obj1 = { |
| 50 |
[Symbol.toPrimitive]: function() { return s1; }, |
| 51 |
toString: err, |
| 52 |
valueOf: err |
| 53 |
}; |
| 54 |
|
| 55 |
var obj2 = { |
| 56 |
toString: function() { return s2; }, |
| 57 |
valueOf: err |
| 58 |
}; |
| 59 |
|
| 60 |
var obj3 = { |
| 61 |
toString: undefined, |
| 62 |
valueOf: function() { return s3; } |
| 63 |
}; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
var C = class { |
| 68 |
[obj1] = 42; |
| 69 |
[obj2] = 43; |
| 70 |
[obj3] = 44; |
| 71 |
} |
| 72 |
|
| 73 |
var c = new C(); |
| 74 |
|
| 75 |
assert.sameValue(Object.hasOwnProperty.call(C.prototype, s1), false); |
| 76 |
assert.sameValue(Object.hasOwnProperty.call(C, s1), false); |
| 77 |
|
| 78 |
verifyProperty(c, s1, { |
| 79 |
value: 42, |
| 80 |
enumerable: true, |
| 81 |
writable: true, |
| 82 |
configurable: true |
| 83 |
}); |
| 84 |
|
| 85 |
assert.sameValue(Object.hasOwnProperty.call(C.prototype, s2), false); |
| 86 |
assert.sameValue(Object.hasOwnProperty.call(C, s2), false); |
| 87 |
|
| 88 |
verifyProperty(c, s2, { |
| 89 |
value: 43, |
| 90 |
enumerable: true, |
| 91 |
writable: true, |
| 92 |
configurable: true |
| 93 |
}); |
| 94 |
|
| 95 |
assert.sameValue(Object.hasOwnProperty.call(C.prototype, s3), false); |
| 96 |
assert.sameValue(Object.hasOwnProperty.call(C, s3), false); |
| 97 |
|
| 98 |
verifyProperty(c, s3, { |
| 99 |
value: 44, |
| 100 |
enumerable: true, |
| 101 |
writable: true, |
| 102 |
configurable: true |
| 103 |
}); |