test262/test/language/statements/class/elements/fields-computed-name-propna...

53 lines
1.4 KiB
JavaScript
Raw Normal View History

// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
2017-10-21 02:39:24 +02:00
/*---
2017-10-31 19:49:00 +01:00
description: class fields forbid PropName 'constructor' (no early error -- PropName of ComputedPropertyName not forbidden value)
2017-10-21 02:39:24 +02:00
esid: sec-class-definitions-static-semantics-early-errors
2017-11-28 18:49:12 +01:00
features: [class, class-fields-public]
2017-10-21 02:39:24 +02:00
info: |
Static Semantics: PropName
...
ComputedPropertyName : [ AssignmentExpression ]
Return empty.
2017-10-21 02:39:24 +02:00
// This test file tests the following early error:
Static Semantics: Early Errors
ClassElement : FieldDefinition;
It is a Syntax Error if PropName of FieldDefinition is "constructor".
DefineField(receiver, fieldRecord)
...
8. If fieldName is a Private Name,
...
9. Else,
a. ...
b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue).
CreateDataPropertyOrThrow ( O, P, V )
2017-10-21 02:39:24 +02:00
...
3. Let success be ? CreateDataProperty(O, P, V).
4. If success is false, throw a TypeError exception.
...
CreateDataProperty ( O, P, V )
...
3. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: true,
[[Configurable]]: true }.
4. Return ? O.[[DefineOwnProperty]](P, newDesc).
---*/
2017-10-21 02:39:24 +02:00
var x = "constructor";
class C1 {
[x];
2017-10-21 02:39:24 +02:00
}
var c1 = new C1();
2017-10-21 02:39:24 +02:00
assert.sameValue(c1.hasOwnProperty("constructor"), true);
assert.sameValue(C1.hasOwnProperty("constructor"), false);