summaryrefslogtreecommitdiff
path: root/src/class-fields/computed-names.case
diff options
context:
space:
mode:
Diffstat (limited to 'src/class-fields/computed-names.case')
-rw-r--r--src/class-fields/computed-names.case70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/class-fields/computed-names.case b/src/class-fields/computed-names.case
new file mode 100644
index 000000000..fcfaf5321
--- /dev/null
+++ b/src/class-fields/computed-names.case
@@ -0,0 +1,70 @@
+// Copyright (C) 2017 the V8 project authors, 2017 Igalia S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: prod-FieldDefinition
+desc: Computed property names
+info: |
+ ClassElement:
+ ...
+ FieldDefinition ;
+
+ FieldDefinition:
+ ClassElementName Initializer_opt
+
+ ClassElementName:
+ PropertyName
+template: default
+includes: [propertyHelper.js]
+features: [computed-property-names]
+---*/
+
+//- setup
+var x = "b";
+
+//- fields
+static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]
+//- assertions
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "a"), false);
+assert.sameValue(Object.hasOwnProperty.call(c, "a"), false);
+
+verifyProperty(C, "a", {
+ value: 39,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "b"), false);
+assert.sameValue(Object.hasOwnProperty.call(C, "b"), false);
+
+verifyProperty(c, "b", {
+ value: 42,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "x"), false);
+assert.sameValue(Object.hasOwnProperty.call(C, "x"), false);
+assert.sameValue(Object.hasOwnProperty.call(c, "x"), false);
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "10"), false);
+assert.sameValue(Object.hasOwnProperty.call(C, "10"), false);
+
+verifyProperty(c, "10", {
+ value: "meep",
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "not initialized"), false);
+assert.sameValue(Object.hasOwnProperty.call(C, "not initialized"), false);
+
+verifyProperty(c, "not initialized", {
+ value: "meep",
+ enumerable: true,
+ writable: true,
+ configurable: true
+});