test262/test/language/expressions/class/fields-static-redeclaration...

51 lines
1.4 KiB
JavaScript

// This file was procedurally generated from the following sources:
// - src/class-fields/static-redeclaration-symbol.case
// - src/class-fields/default/cls-expr.template
/*---
description: Redeclaration of public static fields with the same name (field definitions in a class expression)
esid: prod-FieldDefinition
features: [class, class-fields-public]
flags: [generated]
includes: [propertyHelper.js, compareArray.js]
info: |
2.13.2 Runtime Semantics: ClassDefinitionEvaluation
...
30. Set the value of F's [[Fields]] internal slot to fieldRecords.
...
33. Let result be InitializeStaticFields(F).
InitializeStaticFields(F)
3. Let fieldRecords be the value of F's [[Fields]] internal slot.
4. For each item fieldRecord in order from fieldRecords,
a. If fieldRecord.[[static]] is true, then
i. Perform ? DefineField(F, fieldRecord).
---*/
var x = [];
var y = Symbol();
var C = class {
static [y] = (x.push("a"), "old_value");
static [y] = (x.push("b"), "same_value");
static [y] = (x.push("c"), "same_value");
}
assert.sameValue(Object.hasOwnProperty.call(C.prototype, y), false);
verifyProperty(C, y, {
value: "same_value",
enumerable: true,
writable: true,
configurable: true
});
assert(compareArray(x, ["a", "b", "c"]));
var c = new C();
assert.sameValue(Object.hasOwnProperty.call(c, y), false);
assert(compareArray(x, ["a", "b", "c"]), "static fields are not redefined on class instatiation");