summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeo Balter <leonardo.balter@gmail.com>2017-11-13 17:32:23 -0500
committerLeo Balter <leonardo.balter@gmail.com>2017-11-15 14:31:31 -0500
commit28a2495c3c17e7c92f0be2fc7e952ea8e986b109 (patch)
tree0aec6f20767e9330adcc8e7f65747f47eaea6bc0 /src
parent076ecc38c62f83816d44663f1f96cb5017d72ba8 (diff)
downloadqtdeclarative-testsuites-28a2495c3c17e7c92f0be2fc7e952ea8e986b109.tar.gz
Add more tests for class fields
- Add tests for multiple public fields of the same name - Reorganize fields default templates - Add more tests for redeclaration of fields - Remove non used template - Add tests for computed property names in class fields definitions - Minor test fixes Thanks @andresaraujo for helping with the early review
Diffstat (limited to 'src')
-rw-r--r--src/class-fields/class-evaluation-error/cls-decl.template17
-rw-r--r--src/class-fields/class-evaluation-error/cls-expr.template17
-rw-r--r--src/class-fields/computed-name-referenceerror.case54
-rw-r--r--src/class-fields/computed-name-toprimitive-err.case56
-rw-r--r--src/class-fields/computed-name-toprimitive-returns-noncallable.js55
-rw-r--r--src/class-fields/computed-name-toprimitive-returns-nonobject.js54
-rw-r--r--src/class-fields/computed-name-toprimitive-symbol.case103
-rw-r--r--src/class-fields/computed-name-toprimitive.case100
-rw-r--r--src/class-fields/computed-name-tostring-err.case57
-rw-r--r--src/class-fields/computed-name-valueof-err.case57
-rw-r--r--src/class-fields/computed-names.case2
-rw-r--r--src/class-fields/computed-symbol-names.case2
-rw-r--r--src/class-fields/ctor-called-after-fields-init.case29
-rw-r--r--src/class-fields/default/cls-decl.template15
-rw-r--r--src/class-fields/default/cls-expr.template15
-rw-r--r--src/class-fields/error/cls-decl-new-no-sc-line-generator.template16
-rw-r--r--src/class-fields/init-err-evaluation.case32
-rw-r--r--src/class-fields/init-value-defined-after-class.case45
-rw-r--r--src/class-fields/init-value-incremental.case81
-rw-r--r--src/class-fields/literal-names.case2
-rw-r--r--src/class-fields/private-names.case2
-rw-r--r--src/class-fields/productions/cls-decl-after-same-line-async-gen.template (renamed from src/class-fields/default/cls-decl-after-same-line-async-gen.template)0
-rw-r--r--src/class-fields/productions/cls-decl-after-same-line-async-method.template (renamed from src/class-fields/default/cls-decl-after-same-line-async-method.template)0
-rw-r--r--src/class-fields/productions/cls-decl-after-same-line-gen.template (renamed from src/class-fields/default/cls-decl-after-same-line-gen.template)0
-rw-r--r--src/class-fields/productions/cls-decl-after-same-line-method.template (renamed from src/class-fields/default/cls-decl-after-same-line-method.template)0
-rw-r--r--src/class-fields/productions/cls-decl-after-same-line-static-async-gen.template (renamed from src/class-fields/default/cls-decl-after-same-line-static-async-gen.template)0
-rw-r--r--src/class-fields/productions/cls-decl-after-same-line-static-async-method.template (renamed from src/class-fields/default/cls-decl-after-same-line-static-async-method.template)0
-rw-r--r--src/class-fields/productions/cls-decl-after-same-line-static-gen.template (renamed from src/class-fields/default/cls-decl-after-same-line-static-gen.template)0
-rw-r--r--src/class-fields/productions/cls-decl-after-same-line-static-method.template (renamed from src/class-fields/default/cls-decl-after-same-line-static-method.template)0
-rw-r--r--src/class-fields/productions/cls-decl-multiple-definitions.template (renamed from src/class-fields/default/cls-decl-multiple-definitions.template)0
-rw-r--r--src/class-fields/productions/cls-decl-multiple-stacked-definitions.template (renamed from src/class-fields/default/cls-decl-multiple-stacked-definitions.template)0
-rw-r--r--src/class-fields/productions/cls-decl-new-no-sc-line-method.template (renamed from src/class-fields/default/cls-decl-new-no-sc-line-method.template)0
-rw-r--r--src/class-fields/productions/cls-decl-new-sc-line-generator.template (renamed from src/class-fields/default/cls-decl-new-sc-line-generator.template)0
-rw-r--r--src/class-fields/productions/cls-decl-new-sc-line-method.template (renamed from src/class-fields/default/cls-decl-new-sc-line-method.template)0
-rw-r--r--src/class-fields/productions/cls-decl-regular-definitions.template (renamed from src/class-fields/default/cls-decl-regular-definitions.template)0
-rw-r--r--src/class-fields/productions/cls-decl-same-line-generator.template (renamed from src/class-fields/default/cls-decl-same-line-generator.template)0
-rw-r--r--src/class-fields/productions/cls-decl-same-line-method.template (renamed from src/class-fields/default/cls-decl-same-line-method.template)0
-rw-r--r--src/class-fields/productions/cls-decl-wrapped-in-sc.template (renamed from src/class-fields/default/cls-decl-wrapped-in-sc.template)0
-rw-r--r--src/class-fields/productions/cls-expr-after-same-line-async-gen.template (renamed from src/class-fields/default/cls-expr-after-same-line-async-gen.template)0
-rw-r--r--src/class-fields/productions/cls-expr-after-same-line-async-method.template (renamed from src/class-fields/default/cls-expr-after-same-line-async-method.template)0
-rw-r--r--src/class-fields/productions/cls-expr-after-same-line-gen.template (renamed from src/class-fields/default/cls-expr-after-same-line-gen.template)0
-rw-r--r--src/class-fields/productions/cls-expr-after-same-line-method.template (renamed from src/class-fields/default/cls-expr-after-same-line-method.template)0
-rw-r--r--src/class-fields/productions/cls-expr-after-same-line-static-async-gen.template (renamed from src/class-fields/default/cls-expr-after-same-line-static-async-gen.template)0
-rw-r--r--src/class-fields/productions/cls-expr-after-same-line-static-async-method.template (renamed from src/class-fields/default/cls-expr-after-same-line-static-async-method.template)0
-rw-r--r--src/class-fields/productions/cls-expr-after-same-line-static-gen.template (renamed from src/class-fields/default/cls-expr-after-same-line-static-gen.template)0
-rw-r--r--src/class-fields/productions/cls-expr-after-same-line-static-method.template (renamed from src/class-fields/default/cls-expr-after-same-line-static-method.template)0
-rw-r--r--src/class-fields/productions/cls-expr-multiple-definitions.template (renamed from src/class-fields/default/cls-expr-multiple-definitions.template)0
-rw-r--r--src/class-fields/productions/cls-expr-multiple-stacked-definitions.template (renamed from src/class-fields/default/cls-expr-multiple-stacked-definitions.template)0
-rw-r--r--src/class-fields/productions/cls-expr-new-no-sc-line-method.template (renamed from src/class-fields/default/cls-expr-new-no-sc-line-method.template)0
-rw-r--r--src/class-fields/productions/cls-expr-new-sc-line-generator.template (renamed from src/class-fields/default/cls-expr-new-sc-line-generator.template)0
-rw-r--r--src/class-fields/productions/cls-expr-new-sc-line-method.template (renamed from src/class-fields/default/cls-expr-new-sc-line-method.template)0
-rw-r--r--src/class-fields/productions/cls-expr-regular-definitions.template (renamed from src/class-fields/default/cls-expr-regular-definitions.template)0
-rw-r--r--src/class-fields/productions/cls-expr-same-line-generator.template (renamed from src/class-fields/default/cls-expr-same-line-generator.template)0
-rw-r--r--src/class-fields/productions/cls-expr-same-line-method.template (renamed from src/class-fields/default/cls-expr-same-line-method.template)0
-rw-r--r--src/class-fields/productions/cls-expr-wrapped-in-sc.template (renamed from src/class-fields/default/cls-expr-wrapped-in-sc.template)0
-rw-r--r--src/class-fields/redeclaration-symbol.case52
-rw-r--r--src/class-fields/redeclaration.case52
-rw-r--r--src/class-fields/static-computed-name-toprimitive-symbol.case102
-rw-r--r--src/class-fields/static-computed-name-toprimitive.case99
-rw-r--r--src/class-fields/static-computed-names.case2
-rw-r--r--src/class-fields/static-computed-symbol-names.case12
-rw-r--r--src/class-fields/static-literal-names.case2
-rw-r--r--src/class-fields/static-private-names.case2
-rw-r--r--src/class-fields/static-redeclaration-symbol.case47
-rw-r--r--src/class-fields/static-redeclaration.case47
-rw-r--r--src/class-fields/string-literal-names.case2
66 files changed, 1200 insertions, 30 deletions
diff --git a/src/class-fields/class-evaluation-error/cls-decl.template b/src/class-fields/class-evaluation-error/cls-decl.template
new file mode 100644
index 000000000..2b141c930
--- /dev/null
+++ b/src/class-fields/class-evaluation-error/cls-decl.template
@@ -0,0 +1,17 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+path: language/statements/class/fields-evaluation-error-
+name: field definitions in a class declaration
+features: [class-fields]
+esid: sec-runtime-semantics-classdefinitionevaluation
+---*/
+
+function evaluate() {
+ class C {
+ /*{ fields }*/
+ }
+}
+
+assert.throws(/*{ error }*/, evaluate);
diff --git a/src/class-fields/class-evaluation-error/cls-expr.template b/src/class-fields/class-evaluation-error/cls-expr.template
new file mode 100644
index 000000000..d7cf4339a
--- /dev/null
+++ b/src/class-fields/class-evaluation-error/cls-expr.template
@@ -0,0 +1,17 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+path: language/expressions/class/fields-evaluation-error-
+name: field definitions in a class expression
+features: [class-fields]
+esid: sec-runtime-semantics-classdefinitionevaluation
+---*/
+
+function evaluate() {
+ var C = class {
+ /*{ fields }*/
+ };
+}
+
+assert.throws(/*{ error }*/, evaluate);
diff --git a/src/class-fields/computed-name-referenceerror.case b/src/class-fields/computed-name-referenceerror.case
new file mode 100644
index 000000000..95447eff0
--- /dev/null
+++ b/src/class-fields/computed-name-referenceerror.case
@@ -0,0 +1,54 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: ReferenceError evaluating a computed property name
+info: |
+ Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 27. For each ClassElement e in order from elements
+ a. If IsStatic of me is false, then
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
+ b. Else,
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
+ c. If fields is an abrupt completion, then
+ i. Set the running execution context's LexicalEnvironment to lex.
+ ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
+ iii. Return Completion(status).
+ ...
+
+ Runtime Semantics: ClassElementEvaluation
+
+ ClassElement: static FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
+
+ ClassElement: FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
+
+ Runtime Semantics: ClassFieldDefinitionEvaluation
+ With parameters isStatic and homeObject.
+
+ 1. Let fieldName be the result of evaluating ClassElementName.
+ 2. ReturnIfAbrupt(fieldName).
+ ...
+
+ Runtime Semantics: Evaluation
+ ComputedPropertyName: [ AssignmentExpression ]
+
+ 1. Let exprValue be the result of evaluating AssignmentExpression.
+ 2. Let propName be ? GetValue(exprValue).
+ 3. Return ? ToPropertyKey(propName).
+template: class-evaluation-error
+features: [computed-property-names]
+---*/
+
+//- setup
+function fn() {
+ throw new Test262Error();
+}
+
+//- fields
+[noRef] = fn();
+//- error
+ReferenceError
diff --git a/src/class-fields/computed-name-toprimitive-err.case b/src/class-fields/computed-name-toprimitive-err.case
new file mode 100644
index 000000000..07b991c49
--- /dev/null
+++ b/src/class-fields/computed-name-toprimitive-err.case
@@ -0,0 +1,56 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: Custom error evaluating a computed property name
+info: |
+ Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 27. For each ClassElement e in order from elements
+ a. If IsStatic of me is false, then
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
+ b. Else,
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
+ c. If fields is an abrupt completion, then
+ i. Set the running execution context's LexicalEnvironment to lex.
+ ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
+ iii. Return Completion(status).
+ ...
+
+ Runtime Semantics: ClassElementEvaluation
+
+ ClassElement: static FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
+
+ ClassElement: FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
+
+ Runtime Semantics: ClassFieldDefinitionEvaluation
+ With parameters isStatic and homeObject.
+
+ 1. Let fieldName be the result of evaluating ClassElementName.
+ 2. ReturnIfAbrupt(fieldName).
+ ...
+
+ Runtime Semantics: Evaluation
+ ComputedPropertyName: [ AssignmentExpression ]
+
+ 1. Let exprValue be the result of evaluating AssignmentExpression.
+ 2. Let propName be ? GetValue(exprValue).
+ 3. Return ? ToPropertyKey(propName).
+template: class-evaluation-error
+features: [computed-property-names, Symbol.toPrimitive]
+---*/
+
+//- setup
+var obj = {
+ [Symbol.toPrimitive]: function() {
+ throw new Test262Error();
+ }
+};
+
+//- fields
+[obj]
+//- error
+Test262Error
diff --git a/src/class-fields/computed-name-toprimitive-returns-noncallable.js b/src/class-fields/computed-name-toprimitive-returns-noncallable.js
new file mode 100644
index 000000000..6a69776c2
--- /dev/null
+++ b/src/class-fields/computed-name-toprimitive-returns-noncallable.js
@@ -0,0 +1,55 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: Custom error evaluating a computed property name
+info: |
+ Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 27. For each ClassElement e in order from elements
+ a. If IsStatic of me is false, then
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
+ b. Else,
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
+ c. If fields is an abrupt completion, then
+ i. Set the running execution context's LexicalEnvironment to lex.
+ ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
+ iii. Return Completion(status).
+ ...
+
+ Runtime Semantics: ClassElementEvaluation
+
+ ClassElement: static FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
+
+ ClassElement: FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
+
+ Runtime Semantics: ClassFieldDefinitionEvaluation
+ With parameters isStatic and homeObject.
+
+ 1. Let fieldName be the result of evaluating ClassElementName.
+ 2. ReturnIfAbrupt(fieldName).
+ ...
+
+ Runtime Semantics: Evaluation
+ ComputedPropertyName: [ AssignmentExpression ]
+
+ 1. Let exprValue be the result of evaluating AssignmentExpression.
+ 2. Let propName be ? GetValue(exprValue).
+ 3. Return ? ToPropertyKey(propName).
+template: class-evaluation-error
+features: [computed-property-names, Symbol.toPrimitive]
+---*/
+
+//- setup
+var obj = {
+ [Symbol.toPrimitive]: {}
+};
+
+//- fields
+[obj] = refErrorIfEvaluated;
+//- error
+TypeError
+
diff --git a/src/class-fields/computed-name-toprimitive-returns-nonobject.js b/src/class-fields/computed-name-toprimitive-returns-nonobject.js
new file mode 100644
index 000000000..0fa3ec95a
--- /dev/null
+++ b/src/class-fields/computed-name-toprimitive-returns-nonobject.js
@@ -0,0 +1,54 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: Custom error evaluating a computed property name
+info: |
+ Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 27. For each ClassElement e in order from elements
+ a. If IsStatic of me is false, then
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
+ b. Else,
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
+ c. If fields is an abrupt completion, then
+ i. Set the running execution context's LexicalEnvironment to lex.
+ ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
+ iii. Return Completion(status).
+ ...
+
+ Runtime Semantics: ClassElementEvaluation
+
+ ClassElement: static FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
+
+ ClassElement: FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
+
+ Runtime Semantics: ClassFieldDefinitionEvaluation
+ With parameters isStatic and homeObject.
+
+ 1. Let fieldName be the result of evaluating ClassElementName.
+ 2. ReturnIfAbrupt(fieldName).
+ ...
+
+ Runtime Semantics: Evaluation
+ ComputedPropertyName: [ AssignmentExpression ]
+
+ 1. Let exprValue be the result of evaluating AssignmentExpression.
+ 2. Let propName be ? GetValue(exprValue).
+ 3. Return ? ToPropertyKey(propName).
+template: class-evaluation-error
+features: [computed-property-names, Symbol.toPrimitive]
+---*/
+
+//- setup
+var obj = {
+ [Symbol.toPrimitive]: 42
+};
+
+//- fields
+[obj] = refErrorIfEvaluated;
+//- error
+TypeError
diff --git a/src/class-fields/computed-name-toprimitive-symbol.case b/src/class-fields/computed-name-toprimitive-symbol.case
new file mode 100644
index 000000000..daee6c76f
--- /dev/null
+++ b/src/class-fields/computed-name-toprimitive-symbol.case
@@ -0,0 +1,103 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: ToPrimitive evaluation in the ComputedPropertyName
+info: |
+ Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 27. For each ClassElement e in order from elements
+ a. If IsStatic of me is false, then
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
+ b. Else,
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
+ c. If fields is an abrupt completion, then
+ i. Set the running execution context's LexicalEnvironment to lex.
+ ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
+ iii. Return Completion(status).
+ ...
+
+ Runtime Semantics: ClassElementEvaluation
+
+ ClassElement: static FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
+
+ ClassElement: FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
+
+ Runtime Semantics: ClassFieldDefinitionEvaluation
+ With parameters isStatic and homeObject.
+
+ 1. Let fieldName be the result of evaluating ClassElementName.
+ 2. ReturnIfAbrupt(fieldName).
+ ...
+
+ Runtime Semantics: Evaluation
+ ComputedPropertyName: [ AssignmentExpression ]
+
+ 1. Let exprValue be the result of evaluating AssignmentExpression.
+ 2. Let propName be ? GetValue(exprValue).
+ 3. Return ? ToPropertyKey(propName).
+template: default
+features: [computed-property-names, Symbol.toPrimitive, Symbol]
+includes: [propertyHelper.js]
+---*/
+
+//- setup
+var s1 = Symbol();
+var s2 = Symbol();
+var s3 = Symbol();
+var err = function() { throw new Test262Error(); };
+var obj1 = {
+ [Symbol.toPrimitive]: function() { return s1; },
+ toString: err,
+ valueOf: err
+};
+
+var obj2 = {
+ toString: function() { return s2; },
+ valueOf: err
+};
+
+var obj3 = {
+ toString: undefined,
+ valueOf: function() { return s3; }
+};
+
+//- fields
+[obj1] = 42;
+[obj2] = 43;
+[obj3] = 44;
+//- assertions
+var c = new C();
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, s1), false);
+assert.sameValue(Object.hasOwnProperty.call(C, s1), false);
+
+verifyProperty(c, s1, {
+ value: 42,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, s2), false);
+assert.sameValue(Object.hasOwnProperty.call(C, s2), false);
+
+verifyProperty(c, s2, {
+ value: 43,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, s3), false);
+assert.sameValue(Object.hasOwnProperty.call(C, s3), false);
+
+verifyProperty(c, s3, {
+ value: 44,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
diff --git a/src/class-fields/computed-name-toprimitive.case b/src/class-fields/computed-name-toprimitive.case
new file mode 100644
index 000000000..a8c859b9c
--- /dev/null
+++ b/src/class-fields/computed-name-toprimitive.case
@@ -0,0 +1,100 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: ToPrimitive evaluation in the ComputedPropertyName
+info: |
+ Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 27. For each ClassElement e in order from elements
+ a. If IsStatic of me is false, then
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
+ b. Else,
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
+ c. If fields is an abrupt completion, then
+ i. Set the running execution context's LexicalEnvironment to lex.
+ ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
+ iii. Return Completion(status).
+ ...
+
+ Runtime Semantics: ClassElementEvaluation
+
+ ClassElement: static FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
+
+ ClassElement: FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
+
+ Runtime Semantics: ClassFieldDefinitionEvaluation
+ With parameters isStatic and homeObject.
+
+ 1. Let fieldName be the result of evaluating ClassElementName.
+ 2. ReturnIfAbrupt(fieldName).
+ ...
+
+ Runtime Semantics: Evaluation
+ ComputedPropertyName: [ AssignmentExpression ]
+
+ 1. Let exprValue be the result of evaluating AssignmentExpression.
+ 2. Let propName be ? GetValue(exprValue).
+ 3. Return ? ToPropertyKey(propName).
+template: default
+features: [computed-property-names, Symbol.toPrimitive]
+includes: [propertyHelper.js]
+---*/
+
+//- setup
+var err = function() { throw new Test262Error(); };
+var obj1 = {
+ [Symbol.toPrimitive]: function() { return "d"; },
+ toString: err,
+ valueOf: err
+};
+
+var obj2 = {
+ toString: function() { return "e"; },
+ valueOf: err
+};
+
+var obj3 = {
+ toString: undefined,
+ valueOf: function() { return "f"; }
+};
+
+//- fields
+[obj1] = 42;
+[obj2] = 43;
+[obj3] = 44;
+//- assertions
+var c = new C();
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "d"), false);
+assert.sameValue(Object.hasOwnProperty.call(C, "d"), false);
+
+verifyProperty(c, "d", {
+ value: 42,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "e"), false);
+assert.sameValue(Object.hasOwnProperty.call(C, "e"), false);
+
+verifyProperty(c, "e", {
+ value: 43,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "f"), false);
+assert.sameValue(Object.hasOwnProperty.call(C, "f"), false);
+
+verifyProperty(c, "f", {
+ value: 44,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
diff --git a/src/class-fields/computed-name-tostring-err.case b/src/class-fields/computed-name-tostring-err.case
new file mode 100644
index 000000000..b6d81c06b
--- /dev/null
+++ b/src/class-fields/computed-name-tostring-err.case
@@ -0,0 +1,57 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: Custom error evaluating a computed property name
+info: |
+ Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 27. For each ClassElement e in order from elements
+ a. If IsStatic of me is false, then
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
+ b. Else,
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
+ c. If fields is an abrupt completion, then
+ i. Set the running execution context's LexicalEnvironment to lex.
+ ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
+ iii. Return Completion(status).
+ ...
+
+ Runtime Semantics: ClassElementEvaluation
+
+ ClassElement: static FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
+
+ ClassElement: FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
+
+ Runtime Semantics: ClassFieldDefinitionEvaluation
+ With parameters isStatic and homeObject.
+
+ 1. Let fieldName be the result of evaluating ClassElementName.
+ 2. ReturnIfAbrupt(fieldName).
+ ...
+
+ Runtime Semantics: Evaluation
+ ComputedPropertyName: [ AssignmentExpression ]
+
+ 1. Let exprValue be the result of evaluating AssignmentExpression.
+ 2. Let propName be ? GetValue(exprValue).
+ 3. Return ? ToPropertyKey(propName).
+template: class-evaluation-error
+features: [computed-property-names]
+---*/
+
+//- setup
+var obj = {
+ toString: function() {
+ throw new Test262Error();
+ }
+};
+
+//- fields
+[obj]
+//- error
+Test262Error
+
diff --git a/src/class-fields/computed-name-valueof-err.case b/src/class-fields/computed-name-valueof-err.case
new file mode 100644
index 000000000..232e3c1e9
--- /dev/null
+++ b/src/class-fields/computed-name-valueof-err.case
@@ -0,0 +1,57 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: Custom error evaluating a computed property name
+info: |
+ Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 27. For each ClassElement e in order from elements
+ a. If IsStatic of me is false, then
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
+ b. Else,
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
+ c. If fields is an abrupt completion, then
+ i. Set the running execution context's LexicalEnvironment to lex.
+ ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
+ iii. Return Completion(status).
+ ...
+
+ Runtime Semantics: ClassElementEvaluation
+
+ ClassElement: static FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
+
+ ClassElement: FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
+
+ Runtime Semantics: ClassFieldDefinitionEvaluation
+ With parameters isStatic and homeObject.
+
+ 1. Let fieldName be the result of evaluating ClassElementName.
+ 2. ReturnIfAbrupt(fieldName).
+ ...
+
+ Runtime Semantics: Evaluation
+ ComputedPropertyName: [ AssignmentExpression ]
+
+ 1. Let exprValue be the result of evaluating AssignmentExpression.
+ 2. Let propName be ? GetValue(exprValue).
+ 3. Return ? ToPropertyKey(propName).
+template: class-evaluation-error
+features: [computed-property-names]
+---*/
+
+//- setup
+var obj = {
+ toString: undefined,
+ valueOf: function() {
+ throw new Test262Error();
+ }
+};
+
+//- fields
+[obj]
+//- error
+Test262Error
diff --git a/src/class-fields/computed-names.case b/src/class-fields/computed-names.case
index fed153347..d0ff46c7b 100644
--- a/src/class-fields/computed-names.case
+++ b/src/class-fields/computed-names.case
@@ -13,7 +13,7 @@ info: |
ClassElementName:
PropertyName
-template: default
+template: productions
includes: [propertyHelper.js]
features: [computed-property-names]
---*/
diff --git a/src/class-fields/computed-symbol-names.case b/src/class-fields/computed-symbol-names.case
index 689840c70..106bdc4b1 100644
--- a/src/class-fields/computed-symbol-names.case
+++ b/src/class-fields/computed-symbol-names.case
@@ -13,7 +13,7 @@ info: |
ClassElementName:
PropertyName
-template: default
+template: productions
includes: [propertyHelper.js]
features: [Symbol, computed-property-names]
---*/
diff --git a/src/class-fields/ctor-called-after-fields-init.case b/src/class-fields/ctor-called-after-fields-init.case
new file mode 100644
index 000000000..4ab225392
--- /dev/null
+++ b/src/class-fields/ctor-called-after-fields-init.case
@@ -0,0 +1,29 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: The constructor method is called after the fields are initalized
+info: |
+ [[Construct]] ( argumentsList, newTarget)
+
+ 8. If kind is "base", then
+ a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument).
+ b. Let result be InitializeInstanceFields(thisArgument, F).
+ ...
+ ...
+ 11. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
+ ...
+template: default
+---*/
+
+//- setup
+var ctor;
+//- fields
+constructor() {
+ ctor = this.foo;
+}
+foo = 42;
+//- assertions
+var c = new C();
+
+assert.sameValue(ctor, 42);
diff --git a/src/class-fields/default/cls-decl.template b/src/class-fields/default/cls-decl.template
new file mode 100644
index 000000000..e46471f6a
--- /dev/null
+++ b/src/class-fields/default/cls-decl.template
@@ -0,0 +1,15 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+path: language/statements/class/fields-
+name: field definitions in a class declaration
+features: [class-fields]
+esid: prod-FieldDefinition
+---*/
+
+class C {
+ /*{ fields }*/
+}
+
+/*{ assertions }*/
diff --git a/src/class-fields/default/cls-expr.template b/src/class-fields/default/cls-expr.template
new file mode 100644
index 000000000..5b22f06c8
--- /dev/null
+++ b/src/class-fields/default/cls-expr.template
@@ -0,0 +1,15 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+path: language/expressions/class/fields-
+name: field definitions in a class expression
+features: [class-fields]
+esid: prod-FieldDefinition
+---*/
+
+var C = class {
+ /*{ fields }*/
+}
+
+/*{ assertions }*/
diff --git a/src/class-fields/error/cls-decl-new-no-sc-line-generator.template b/src/class-fields/error/cls-decl-new-no-sc-line-generator.template
deleted file mode 100644
index c7aebcdef..000000000
--- a/src/class-fields/error/cls-decl-new-no-sc-line-generator.template
+++ /dev/null
@@ -1,16 +0,0 @@
-// 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.
-
-/*---
-path: language/statements/class/fields-new-no-sc-line-gen-
-name: ASI prevents a following generator method
-features: [class-fields, generators]
-negative:
- type: SyntaxError
- phase: early
----*/
-
-class C {
- /*{ fields }*/
- *m() { return 42; }
-}
diff --git a/src/class-fields/init-err-evaluation.case b/src/class-fields/init-err-evaluation.case
new file mode 100644
index 000000000..caac1c029
--- /dev/null
+++ b/src/class-fields/init-err-evaluation.case
@@ -0,0 +1,32 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: Return abrupt completion evaluating the field initializer
+info: |
+ [[Construct]] ( argumentsList, newTarget)
+
+ 8. If kind is "base", then
+ a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument).
+ b. Let result be InitializeInstanceFields(thisArgument, F).
+ ...
+ ...
+ 11. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
+ ...
+template: default
+---*/
+
+//- setup
+var x = 0;
+function fn1() { x += 1; }
+function fn2() { throw new Test262Error(); }
+//- fields
+x = fn1();
+y = fn2();
+z = fn1();
+//- assertions
+assert.throws(Test262Error, function() {
+ new C();
+});
+
+assert.sameValue(x, 1);
diff --git a/src/class-fields/init-value-defined-after-class.case b/src/class-fields/init-value-defined-after-class.case
new file mode 100644
index 000000000..51c754c78
--- /dev/null
+++ b/src/class-fields/init-value-defined-after-class.case
@@ -0,0 +1,45 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: The initializer value is defined after the class evaluation
+info: |
+ [[Construct]] ( argumentsList, newTarget)
+
+ 8. If kind is "base", then
+ a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument).
+ b. Let result be InitializeInstanceFields(thisArgument, F).
+ ...
+ ...
+ 11. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
+ ...
+template: default
+features: [computed-property-names]
+includes: [propertyHelper.js]
+---*/
+
+//- setup
+var x = false;
+//- fields
+[x] = x;
+//- assertions
+var c1 = new C();
+
+x = true;
+var c2 = new C();
+
+verifyProperty(c1, "false", {
+ value: false,
+ enumerable: true,
+ configurable: true,
+ writable: true,
+});
+verifyProperty(c2, "false", {
+ value: true,
+ enumerable: true,
+ configurable: true,
+ writable: true,
+});
+
+assert.sameValue(c1.hasOwnProperty("true"), false);
+assert.sameValue(c2.hasOwnProperty("true"), false);
diff --git a/src/class-fields/init-value-incremental.case b/src/class-fields/init-value-incremental.case
new file mode 100644
index 000000000..b3cd5a8c0
--- /dev/null
+++ b/src/class-fields/init-value-incremental.case
@@ -0,0 +1,81 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: The initializer value is defined during the class instatiation
+info: |
+ Runtime Semantics: ClassDefinitionEvaluation
+
+ 27. For each ClassElement e in order from elements
+ ...
+ d. Append to fieldRecords the elements of fields.
+ ...
+ 33. Let result be InitializeStaticFields(F).
+ ...
+
+ [[Construct]] ( argumentsList, newTarget)
+
+ 8. If kind is "base", then
+ a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument).
+ b. Let result be InitializeInstanceFields(thisArgument, F).
+ ...
+ ...
+ 11. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
+ ...
+template: default
+features: [computed-property-names]
+includes: [propertyHelper.js]
+---*/
+
+//- setup
+var x = 0;
+//- fields
+static [x++] = x++;
+[x++] = x++;
+static [x++] = x++;
+[x++] = x++;
+//- assertions
+var c1 = new C();
+var c2 = new C();
+
+verifyProperty(C, "0", {
+ value: 4,
+ enumerable: true,
+ configurable: true,
+ writable: true,
+});
+
+verifyProperty(C, "2", {
+ value: 5,
+ enumerable: true,
+ configurable: true,
+ writable: true,
+});
+
+verifyProperty(c1, "1", {
+ value: 6,
+ enumerable: true,
+ configurable: true,
+ writable: true,
+});
+
+verifyProperty(c1, "3", {
+ value: 7,
+ enumerable: true,
+ configurable: true,
+ writable: true,
+});
+
+verifyProperty(c2, "1", {
+ value: 8,
+ enumerable: true,
+ configurable: true,
+ writable: true,
+});
+
+verifyProperty(c2, "3", {
+ value: 9,
+ enumerable: true,
+ configurable: true,
+ writable: true,
+});
diff --git a/src/class-fields/literal-names.case b/src/class-fields/literal-names.case
index 5a7869809..3637efbca 100644
--- a/src/class-fields/literal-names.case
+++ b/src/class-fields/literal-names.case
@@ -13,7 +13,7 @@ info: |
ClassElementName:
PropertyName
-template: default
+template: productions
includes: [propertyHelper.js]
---*/
diff --git a/src/class-fields/private-names.case b/src/class-fields/private-names.case
index 6987bcd7b..24e9a7c2c 100644
--- a/src/class-fields/private-names.case
+++ b/src/class-fields/private-names.case
@@ -16,7 +16,7 @@ info: |
PrivateName:
#IdentifierName
-template: default
+template: productions
---*/
//- fields
diff --git a/src/class-fields/default/cls-decl-after-same-line-async-gen.template b/src/class-fields/productions/cls-decl-after-same-line-async-gen.template
index 81d3548cf..81d3548cf 100644
--- a/src/class-fields/default/cls-decl-after-same-line-async-gen.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-async-gen.template
diff --git a/src/class-fields/default/cls-decl-after-same-line-async-method.template b/src/class-fields/productions/cls-decl-after-same-line-async-method.template
index 62b48966f..62b48966f 100644
--- a/src/class-fields/default/cls-decl-after-same-line-async-method.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-async-method.template
diff --git a/src/class-fields/default/cls-decl-after-same-line-gen.template b/src/class-fields/productions/cls-decl-after-same-line-gen.template
index 7ca401a7c..7ca401a7c 100644
--- a/src/class-fields/default/cls-decl-after-same-line-gen.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-gen.template
diff --git a/src/class-fields/default/cls-decl-after-same-line-method.template b/src/class-fields/productions/cls-decl-after-same-line-method.template
index ab59c5bb9..ab59c5bb9 100644
--- a/src/class-fields/default/cls-decl-after-same-line-method.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-method.template
diff --git a/src/class-fields/default/cls-decl-after-same-line-static-async-gen.template b/src/class-fields/productions/cls-decl-after-same-line-static-async-gen.template
index 68d9687cd..68d9687cd 100644
--- a/src/class-fields/default/cls-decl-after-same-line-static-async-gen.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-static-async-gen.template
diff --git a/src/class-fields/default/cls-decl-after-same-line-static-async-method.template b/src/class-fields/productions/cls-decl-after-same-line-static-async-method.template
index 5b5bb56a1..5b5bb56a1 100644
--- a/src/class-fields/default/cls-decl-after-same-line-static-async-method.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-static-async-method.template
diff --git a/src/class-fields/default/cls-decl-after-same-line-static-gen.template b/src/class-fields/productions/cls-decl-after-same-line-static-gen.template
index 1c9137c27..1c9137c27 100644
--- a/src/class-fields/default/cls-decl-after-same-line-static-gen.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-static-gen.template
diff --git a/src/class-fields/default/cls-decl-after-same-line-static-method.template b/src/class-fields/productions/cls-decl-after-same-line-static-method.template
index 2d1351265..2d1351265 100644
--- a/src/class-fields/default/cls-decl-after-same-line-static-method.template
+++ b/src/class-fields/productions/cls-decl-after-same-line-static-method.template
diff --git a/src/class-fields/default/cls-decl-multiple-definitions.template b/src/class-fields/productions/cls-decl-multiple-definitions.template
index 583c8f377..583c8f377 100644
--- a/src/class-fields/default/cls-decl-multiple-definitions.template
+++ b/src/class-fields/productions/cls-decl-multiple-definitions.template
diff --git a/src/class-fields/default/cls-decl-multiple-stacked-definitions.template b/src/class-fields/productions/cls-decl-multiple-stacked-definitions.template
index 7c95c62ff..7c95c62ff 100644
--- a/src/class-fields/default/cls-decl-multiple-stacked-definitions.template
+++ b/src/class-fields/productions/cls-decl-multiple-stacked-definitions.template
diff --git a/src/class-fields/default/cls-decl-new-no-sc-line-method.template b/src/class-fields/productions/cls-decl-new-no-sc-line-method.template
index 630d9c51e..630d9c51e 100644
--- a/src/class-fields/default/cls-decl-new-no-sc-line-method.template
+++ b/src/class-fields/productions/cls-decl-new-no-sc-line-method.template
diff --git a/src/class-fields/default/cls-decl-new-sc-line-generator.template b/src/class-fields/productions/cls-decl-new-sc-line-generator.template
index b347c09b9..b347c09b9 100644
--- a/src/class-fields/default/cls-decl-new-sc-line-generator.template
+++ b/src/class-fields/productions/cls-decl-new-sc-line-generator.template
diff --git a/src/class-fields/default/cls-decl-new-sc-line-method.template b/src/class-fields/productions/cls-decl-new-sc-line-method.template
index 4f714e29f..4f714e29f 100644
--- a/src/class-fields/default/cls-decl-new-sc-line-method.template
+++ b/src/class-fields/productions/cls-decl-new-sc-line-method.template
diff --git a/src/class-fields/default/cls-decl-regular-definitions.template b/src/class-fields/productions/cls-decl-regular-definitions.template
index 4ccdd76f7..4ccdd76f7 100644
--- a/src/class-fields/default/cls-decl-regular-definitions.template
+++ b/src/class-fields/productions/cls-decl-regular-definitions.template
diff --git a/src/class-fields/default/cls-decl-same-line-generator.template b/src/class-fields/productions/cls-decl-same-line-generator.template
index 420268b69..420268b69 100644
--- a/src/class-fields/default/cls-decl-same-line-generator.template
+++ b/src/class-fields/productions/cls-decl-same-line-generator.template
diff --git a/src/class-fields/default/cls-decl-same-line-method.template b/src/class-fields/productions/cls-decl-same-line-method.template
index 3b1be5f58..3b1be5f58 100644
--- a/src/class-fields/default/cls-decl-same-line-method.template
+++ b/src/class-fields/productions/cls-decl-same-line-method.template
diff --git a/src/class-fields/default/cls-decl-wrapped-in-sc.template b/src/class-fields/productions/cls-decl-wrapped-in-sc.template
index b76403262..b76403262 100644
--- a/src/class-fields/default/cls-decl-wrapped-in-sc.template
+++ b/src/class-fields/productions/cls-decl-wrapped-in-sc.template
diff --git a/src/class-fields/default/cls-expr-after-same-line-async-gen.template b/src/class-fields/productions/cls-expr-after-same-line-async-gen.template
index a86b3256a..a86b3256a 100644
--- a/src/class-fields/default/cls-expr-after-same-line-async-gen.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-async-gen.template
diff --git a/src/class-fields/default/cls-expr-after-same-line-async-method.template b/src/class-fields/productions/cls-expr-after-same-line-async-method.template
index f1a0f2695..f1a0f2695 100644
--- a/src/class-fields/default/cls-expr-after-same-line-async-method.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-async-method.template
diff --git a/src/class-fields/default/cls-expr-after-same-line-gen.template b/src/class-fields/productions/cls-expr-after-same-line-gen.template
index 1434038df..1434038df 100644
--- a/src/class-fields/default/cls-expr-after-same-line-gen.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-gen.template
diff --git a/src/class-fields/default/cls-expr-after-same-line-method.template b/src/class-fields/productions/cls-expr-after-same-line-method.template
index 9f25e8b48..9f25e8b48 100644
--- a/src/class-fields/default/cls-expr-after-same-line-method.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-method.template
diff --git a/src/class-fields/default/cls-expr-after-same-line-static-async-gen.template b/src/class-fields/productions/cls-expr-after-same-line-static-async-gen.template
index bda88adcc..bda88adcc 100644
--- a/src/class-fields/default/cls-expr-after-same-line-static-async-gen.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-static-async-gen.template
diff --git a/src/class-fields/default/cls-expr-after-same-line-static-async-method.template b/src/class-fields/productions/cls-expr-after-same-line-static-async-method.template
index f9e61dc7f..f9e61dc7f 100644
--- a/src/class-fields/default/cls-expr-after-same-line-static-async-method.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-static-async-method.template
diff --git a/src/class-fields/default/cls-expr-after-same-line-static-gen.template b/src/class-fields/productions/cls-expr-after-same-line-static-gen.template
index 278275a30..278275a30 100644
--- a/src/class-fields/default/cls-expr-after-same-line-static-gen.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-static-gen.template
diff --git a/src/class-fields/default/cls-expr-after-same-line-static-method.template b/src/class-fields/productions/cls-expr-after-same-line-static-method.template
index 2b6f3e4dd..2b6f3e4dd 100644
--- a/src/class-fields/default/cls-expr-after-same-line-static-method.template
+++ b/src/class-fields/productions/cls-expr-after-same-line-static-method.template
diff --git a/src/class-fields/default/cls-expr-multiple-definitions.template b/src/class-fields/productions/cls-expr-multiple-definitions.template
index 00c2175eb..00c2175eb 100644
--- a/src/class-fields/default/cls-expr-multiple-definitions.template
+++ b/src/class-fields/productions/cls-expr-multiple-definitions.template
diff --git a/src/class-fields/default/cls-expr-multiple-stacked-definitions.template b/src/class-fields/productions/cls-expr-multiple-stacked-definitions.template
index dd920d97e..dd920d97e 100644
--- a/src/class-fields/default/cls-expr-multiple-stacked-definitions.template
+++ b/src/class-fields/productions/cls-expr-multiple-stacked-definitions.template
diff --git a/src/class-fields/default/cls-expr-new-no-sc-line-method.template b/src/class-fields/productions/cls-expr-new-no-sc-line-method.template
index 320f62682..320f62682 100644
--- a/src/class-fields/default/cls-expr-new-no-sc-line-method.template
+++ b/src/class-fields/productions/cls-expr-new-no-sc-line-method.template
diff --git a/src/class-fields/default/cls-expr-new-sc-line-generator.template b/src/class-fields/productions/cls-expr-new-sc-line-generator.template
index e956c11b6..e956c11b6 100644
--- a/src/class-fields/default/cls-expr-new-sc-line-generator.template
+++ b/src/class-fields/productions/cls-expr-new-sc-line-generator.template
diff --git a/src/class-fields/default/cls-expr-new-sc-line-method.template b/src/class-fields/productions/cls-expr-new-sc-line-method.template
index 8be8ce2ed..8be8ce2ed 100644
--- a/src/class-fields/default/cls-expr-new-sc-line-method.template
+++ b/src/class-fields/productions/cls-expr-new-sc-line-method.template
diff --git a/src/class-fields/default/cls-expr-regular-definitions.template b/src/class-fields/productions/cls-expr-regular-definitions.template
index 630c04f41..630c04f41 100644
--- a/src/class-fields/default/cls-expr-regular-definitions.template
+++ b/src/class-fields/productions/cls-expr-regular-definitions.template
diff --git a/src/class-fields/default/cls-expr-same-line-generator.template b/src/class-fields/productions/cls-expr-same-line-generator.template
index 286d60af3..286d60af3 100644
--- a/src/class-fields/default/cls-expr-same-line-generator.template
+++ b/src/class-fields/productions/cls-expr-same-line-generator.template
diff --git a/src/class-fields/default/cls-expr-same-line-method.template b/src/class-fields/productions/cls-expr-same-line-method.template
index d565e5c5e..d565e5c5e 100644
--- a/src/class-fields/default/cls-expr-same-line-method.template
+++ b/src/class-fields/productions/cls-expr-same-line-method.template
diff --git a/src/class-fields/default/cls-expr-wrapped-in-sc.template b/src/class-fields/productions/cls-expr-wrapped-in-sc.template
index 4f7397057..4f7397057 100644
--- a/src/class-fields/default/cls-expr-wrapped-in-sc.template
+++ b/src/class-fields/productions/cls-expr-wrapped-in-sc.template
diff --git a/src/class-fields/redeclaration-symbol.case b/src/class-fields/redeclaration-symbol.case
new file mode 100644
index 000000000..fa2d32ed7
--- /dev/null
+++ b/src/class-fields/redeclaration-symbol.case
@@ -0,0 +1,52 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: Redeclaration of public fields with the same name
+info: |
+ 2.13.2 Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 30. Set the value of F's [[Fields]] internal slot to fieldRecords.
+ ...
+
+ 2.14 [[Construct]] ( argumentsList, newTarget)
+
+ ...
+ 8. If kind is "base", then
+ ...
+ b. Let result be InitializeInstanceFields(thisArgument, F).
+ ...
+
+ 2.9 InitializeInstanceFields ( O, constructor )
+
+ 3. Let fieldRecords be the value of constructor's [[Fields]] internal slot.
+ 4. For each item fieldRecord in order from fieldRecords,
+ a. If fieldRecord.[[static]] is false, then
+ i. Perform ? DefineField(O, fieldRecord).
+
+template: default
+includes: [propertyHelper.js, compareArray.js]
+---*/
+
+//- setup
+var x = [];
+var y = Symbol();
+//- fields
+[y] = (x.push("a"), "old_value");
+[y] = (x.push("b"), "same_value");
+[y] = (x.push("c"), "same_value");
+//- assertions
+var c = new C();
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, y), false);
+assert.sameValue(Object.hasOwnProperty.call(C, y), false);
+
+verifyProperty(c, y, {
+ value: "same_value",
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+assert(compareArray(x, ["a", "b", "c"]));
diff --git a/src/class-fields/redeclaration.case b/src/class-fields/redeclaration.case
new file mode 100644
index 000000000..e67c14536
--- /dev/null
+++ b/src/class-fields/redeclaration.case
@@ -0,0 +1,52 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: Redeclaration of public fields with the same name
+info: |
+ 2.13.2 Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 30. Set the value of F's [[Fields]] internal slot to fieldRecords.
+ ...
+
+ 2.14 [[Construct]] ( argumentsList, newTarget)
+
+ ...
+ 8. If kind is "base", then
+ ...
+ b. Let result be InitializeInstanceFields(thisArgument, F).
+ ...
+
+ 2.9 InitializeInstanceFields ( O, constructor )
+
+ 3. Let fieldRecords be the value of constructor's [[Fields]] internal slot.
+ 4. For each item fieldRecord in order from fieldRecords,
+ a. If fieldRecord.[[static]] is false, then
+ i. Perform ? DefineField(O, fieldRecord).
+
+template: default
+includes: [propertyHelper.js, compareArray.js]
+---*/
+
+//- setup
+var x = [];
+//- fields
+y = (x.push("a"), "old_value");
+["y"] = (x.push("b"), "another_value");
+"y" = (x.push("c"), "same_value");
+y = (x.push("d"), "same_value");
+//- assertions
+var c = new C();
+
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "y"), false);
+assert.sameValue(Object.hasOwnProperty.call(C, "y"), false);
+
+verifyProperty(c, "y", {
+ value: "same_value",
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+assert(compareArray(x, ["a", "b", "c", "d"]));
diff --git a/src/class-fields/static-computed-name-toprimitive-symbol.case b/src/class-fields/static-computed-name-toprimitive-symbol.case
new file mode 100644
index 000000000..49fc61c49
--- /dev/null
+++ b/src/class-fields/static-computed-name-toprimitive-symbol.case
@@ -0,0 +1,102 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: ToPrimitive evaluation in the ComputedPropertyName
+info: |
+ Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 27. For each ClassElement e in order from elements
+ a. If IsStatic of me is false, then
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
+ b. Else,
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
+ c. If fields is an abrupt completion, then
+ i. Set the running execution context's LexicalEnvironment to lex.
+ ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
+ iii. Return Completion(status).
+ ...
+
+ Runtime Semantics: ClassElementEvaluation
+
+ ClassElement: static FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
+
+ ClassElement: FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
+
+ Runtime Semantics: ClassFieldDefinitionEvaluation
+ With parameters isStatic and homeObject.
+
+ 1. Let fieldName be the result of evaluating ClassElementName.
+ 2. ReturnIfAbrupt(fieldName).
+ ...
+
+ Runtime Semantics: Evaluation
+ ComputedPropertyName: [ AssignmentExpression ]
+
+ 1. Let exprValue be the result of evaluating AssignmentExpression.
+ 2. Let propName be ? GetValue(exprValue).
+ 3. Return ? ToPropertyKey(propName).
+template: default
+features: [computed-property-names, Symbol.toPrimitive, Symbol]
+includes: [propertyHelper.js]
+---*/
+
+//- setup
+var s1 = Symbol();
+var s2 = Symbol();
+var s3 = Symbol();
+var err = function() { throw new Test262Error(); };
+var obj1 = {
+ [Symbol.toPrimitive]: function() { return s1; },
+ toString: err,
+ valueOf: err
+};
+
+var obj2 = {
+ toString: function() { return s2; },
+ valueOf: err
+};
+
+var obj3 = {
+ toString: undefined,
+ valueOf: function() { return s3; }
+};
+
+//- fields
+static [obj1] = 42;
+static [obj2] = 43;
+static [obj3] = 44;
+//- assertions
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, s1), false);
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, s2), false);
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, s3), false);
+
+verifyProperty(C, s1, {
+ value: 42,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+verifyProperty(C, s2, {
+ value: 43,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+verifyProperty(C, s3, {
+ value: 44,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+var c = new C();
+
+assert.sameValue(Object.hasOwnProperty.call(c, s1), false);
+assert.sameValue(Object.hasOwnProperty.call(c, s2), false);
+assert.sameValue(Object.hasOwnProperty.call(c, s3), false);
diff --git a/src/class-fields/static-computed-name-toprimitive.case b/src/class-fields/static-computed-name-toprimitive.case
new file mode 100644
index 000000000..133eff72b
--- /dev/null
+++ b/src/class-fields/static-computed-name-toprimitive.case
@@ -0,0 +1,99 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: ToPrimitive evaluation in the ComputedPropertyName
+info: |
+ Runtime Semantics: ClassDefinitionEvaluation
+
+ ...
+ 27. For each ClassElement e in order from elements
+ a. If IsStatic of me is false, then
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments proto and false.
+ b. Else,
+ i. Let fields be the result of performing ClassElementEvaluation for e with arguments F and false.
+ c. If fields is an abrupt completion, then
+ i. Set the running execution context's LexicalEnvironment to lex.
+ ii. Set the running execution context's PrivateNameEnvironment to outerPrivateEnvironment.
+ iii. Return Completion(status).
+ ...
+
+ Runtime Semantics: ClassElementEvaluation
+
+ ClassElement: static FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter true and object.
+
+ ClassElement: FieldDefinition;
+ Return ClassFieldDefinitionEvaluation of FieldDefinition with parameter false and object.
+
+ Runtime Semantics: ClassFieldDefinitionEvaluation
+ With parameters isStatic and homeObject.
+
+ 1. Let fieldName be the result of evaluating ClassElementName.
+ 2. ReturnIfAbrupt(fieldName).
+ ...
+
+ Runtime Semantics: Evaluation
+ ComputedPropertyName: [ AssignmentExpression ]
+
+ 1. Let exprValue be the result of evaluating AssignmentExpression.
+ 2. Let propName be ? GetValue(exprValue).
+ 3. Return ? ToPropertyKey(propName).
+template: default
+features: [computed-property-names, Symbol.toPrimitive]
+includes: [propertyHelper.js]
+---*/
+
+//- setup
+var err = function() { throw new Test262Error(); };
+var obj1 = {
+ [Symbol.toPrimitive]: function() { return "d"; },
+ toString: err,
+ valueOf: err
+};
+
+var obj2 = {
+ toString: function() { return "e"; },
+ valueOf: err
+};
+
+var obj3 = {
+ toString: undefined,
+ valueOf: function() { return "f"; }
+};
+
+//- fields
+static [obj1] = 42;
+static [obj2] = 43;
+static [obj3] = 44;
+//- assertions
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "d"), false);
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "e"), false);
+assert.sameValue(Object.hasOwnProperty.call(C.prototype, "f"), false);
+
+verifyProperty(C, "d", {
+ value: 42,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+verifyProperty(C, "e", {
+ value: 43,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+verifyProperty(C, "f", {
+ value: 44,
+ enumerable: true,
+ writable: true,
+ configurable: true
+});
+
+var c = new C();
+
+assert.sameValue(Object.hasOwnProperty.call(c, "d"), false);
+assert.sameValue(Object.hasOwnProperty.call(c, "e"), false);
+assert.sameValue(Object.hasOwnProperty.call(c, "f"), false);
diff --git a/src/class-fields/static-computed-names.case b/src/class-fields/static-computed-names.case
index c1d826c9d..74fb407b5 100644
--- a/src/class-fields/static-computed-names.case
+++ b/src/class-fields/static-computed-names.case
@@ -14,7 +14,7 @@ info: |
ClassElementName:
PropertyName
-template: default
+template: productions
includes: [propertyHelper.js]
features: [computed-property-names]
---*/
diff --git a/src/class-fields/static-computed-symbol-names.case b/src/class-fields/static-computed-symbol-names.case
index be0c75c49..79ec1284c 100644
--- a/src/class-fields/static-computed-symbol-names.case
+++ b/src/class-fields/static-computed-symbol-names.case
@@ -13,7 +13,7 @@ info: |
ClassElementName:
PropertyName
-template: default
+template: productions
includes: [propertyHelper.js]
features: [Symbol, computed-property-names]
---*/
@@ -23,12 +23,12 @@ var x = Symbol();
var y = Symbol();
//- fields
-[x]; [y] = 42
+static [x]; static [y] = 42
//- assertions
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);
-verifyProperty(c, x, {
+verifyProperty(C, x, {
value: undefined,
enumerable: true,
writable: true,
@@ -36,9 +36,9 @@ verifyProperty(c, x, {
});
assert.sameValue(Object.hasOwnProperty.call(C.prototype, y), false);
-assert.sameValue(Object.hasOwnProperty.call(C, y), false);
+assert.sameValue(Object.hasOwnProperty.call(c, y), false);
-verifyProperty(c, y, {
+verifyProperty(C, y, {
value: 42,
enumerable: true,
writable: true,
diff --git a/src/class-fields/static-literal-names.case b/src/class-fields/static-literal-names.case
index e10ab4854..9fd2327a4 100644
--- a/src/class-fields/static-literal-names.case
+++ b/src/class-fields/static-literal-names.case
@@ -13,7 +13,7 @@ info: |
ClassElementName:
PropertyName
-template: default
+template: productions
includes: [propertyHelper.js]
---*/
diff --git a/src/class-fields/static-private-names.case b/src/class-fields/static-private-names.case
index 464b53a9e..10791399f 100644
--- a/src/class-fields/static-private-names.case
+++ b/src/class-fields/static-private-names.case
@@ -16,7 +16,7 @@ info: |
PrivateName:
#IdentifierName
-template: default
+template: productions
---*/
//- fields
diff --git a/src/class-fields/static-redeclaration-symbol.case b/src/class-fields/static-redeclaration-symbol.case
new file mode 100644
index 000000000..cc811207d
--- /dev/null
+++ b/src/class-fields/static-redeclaration-symbol.case
@@ -0,0 +1,47 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: Redeclaration of public static fields with the same name
+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).
+
+template: default
+includes: [propertyHelper.js, compareArray.js]
+---*/
+
+//- setup
+var x = [];
+var y = Symbol();
+//- fields
+static [y] = (x.push("a"), "old_value");
+static [y] = (x.push("b"), "same_value");
+static [y] = (x.push("c"), "same_value");
+//- assertions
+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");
diff --git a/src/class-fields/static-redeclaration.case b/src/class-fields/static-redeclaration.case
new file mode 100644
index 000000000..46bfc9ddd
--- /dev/null
+++ b/src/class-fields/static-redeclaration.case
@@ -0,0 +1,47 @@
+// Copyright (C) 2017 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+desc: Redeclaration of public static fields with the same name
+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).
+
+template: default
+includes: [propertyHelper.js, compareArray.js]
+---*/
+
+//- setup
+var x = [];
+//- fields
+static y = (x.push("a"), "old_value");
+static ["y"] = (x.push("b"), "another_value");
+static "y" = (x.push("c"), "same_value");
+static y = (x.push("d"), "same_value");
+//- assertions
+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", "d"]));
+
+var c = new C();
+assert.sameValue(Object.hasOwnProperty.call(c, "y"), false);
+
+assert(compareArray(x, ["a", "b", "c", "d"]), "static fields are not redefined on class instatiation");
diff --git a/src/class-fields/string-literal-names.case b/src/class-fields/string-literal-names.case
index 073ce8641..bc22ba9e0 100644
--- a/src/class-fields/string-literal-names.case
+++ b/src/class-fields/string-literal-names.case
@@ -13,7 +13,7 @@ info: |
ClassElementName:
PropertyName
-template: default
+template: productions
includes: [propertyHelper.js]
---*/