diff --git a/test/language/expressions/class/fields-computed-name-static-propname-prototype.js b/test/language/expressions/class/fields-computed-name-static-propname-prototype.js index ab2c5f272b..e1366634d8 100644 --- a/test/language/expressions/class/fields-computed-name-static-propname-prototype.js +++ b/test/language/expressions/class/fields-computed-name-static-propname-prototype.js @@ -1,30 +1,32 @@ // Copyright (C) 2017 Valerie Young. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: static class fields forbid PropName 'prototype' (no early error -- PropName of ComputedPropertyName not forbidden value) +description: static class fields forbid PropName 'prototype' (no early error -- PropName of ComputedPropertyName) esid: sec-class-definitions-static-semantics-early-errors -features: [class, class-fields-public] +features: [class, class-static-fields-public] info: | - Static Semantics: PropName - ... - ComputedPropertyName : [ AssignmentExpression ] - Return empty. + 14.6.13 Runtime Semantics: ClassDefinitionEvaluation + ... + 16. Perform MakeConstructor(F, false, proto). + ... - // This test file tests the following early error: - Static Semantics: Early Errors + 9.2.10 MakeConstructor ( F [ , writablePrototype [ , prototype ] ] ) - ClassElement : static FieldDefinition; - It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". - -negative: - phase: parse - type: SyntaxError + 6. Perform ! DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]: prototype, + [[Writable]]: writablePrototype, [[Enumerable]]: false, [[Configurable]]: false }). ---*/ -throw "Test262: This statement should not be evaluated."; - var x = "prototype"; -var C = class { - static [x]; -}; + +assert.throws(TypeError, function() { + (0, class { + static [x] = 42; + }); +}); + +assert.throws(TypeError, function() { + (0, class { + static [x]; + }); +}); diff --git a/test/language/statements/class/fields-computed-name-propname-constructor.js b/test/language/statements/class/fields-computed-name-propname-constructor.js index 46e19b73a8..6ea84326e7 100644 --- a/test/language/statements/class/fields-computed-name-propname-constructor.js +++ b/test/language/statements/class/fields-computed-name-propname-constructor.js @@ -17,20 +17,37 @@ info: | ClassElement : FieldDefinition; It is a Syntax Error if PropName of FieldDefinition is "constructor". -negative: - phase: parse - type: SyntaxError + DefineField(receiver, fieldRecord) + ... + 8. If fieldName is a Private Name, + ... + 9. Else, + a. ... + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + + CreateDataPropertyOrThrow ( O, P, V ) + + ... + 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). +includes: [propertyHelper.js] ---*/ -throw "Test262: This statement should not be evaluated."; - var x = "constructor"; -class C { +class C1 { [x]; } -var c = new C(); +var c1 = new C1(); -assert.sameValue(c.hasOwnProperty("constructor"), true); -assert.sameValue(C.hasOwnProperty("constructor"), false); +assert.sameValue(c1.hasOwnProperty("constructor"), true); +assert.sameValue(C1.hasOwnProperty("constructor"), false); diff --git a/test/language/statements/class/fields-computed-name-static-computed-var-propname-constructor.js b/test/language/statements/class/fields-computed-name-static-computed-var-propname-constructor.js index 1963899949..1d242df881 100644 --- a/test/language/statements/class/fields-computed-name-static-computed-var-propname-constructor.js +++ b/test/language/statements/class/fields-computed-name-static-computed-var-propname-constructor.js @@ -1,7 +1,7 @@ -// Copyright (C) 2017 Valerie Young. All rights reserved. +// Copyright (C) 2017 Leo Balter. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: static class fields forbid PropName 'prototype' (no early error -- PropName of ComputedPropertyName not forbidden value) +description: static class fields forbid PropName 'constructor' (no early error -- PropName of ComputedPropertyName not forbidden value) esid: sec-class-definitions-static-semantics-early-errors features: [class, class-static-fields-public] info: | @@ -10,22 +10,71 @@ info: | ComputedPropertyName : [ AssignmentExpression ] Return empty. + This test file tests the following early error is only valid for a matching PropName: - // This test file tests the following early error: Static Semantics: Early Errors - ClassElement : static FieldDefinition; + ClassElement : static FieldDefinition; It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". -negative: - phase: parse - type: SyntaxError + -- IDK what is calling InitializeClassElements but I guess it's supposed to be called to + -- set the fields + InitializeClassElements(F, proto) + + ... + 6. For each item element in order from elements, + a. If element.[[Kind]] is "field" and element.[[Placement]] is "static" or "prototype", + ... + ii. Let receiver be F if element.[[Placement]] is "static", else let receiver be proto. + iii. Perform ? DefineClassElement(receiver, element). + + -- DefineClassElement is probably DefineField in the class fields proposal + + DefineField(receiver, fieldRecord) + + ... + 8. If fieldName is a Private Name, + ... + 9. Else, + a. ... + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + + CreateDataPropertyOrThrow ( O, P, V ) + + ... + 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). +includes: [propertyHelper.js] ---*/ -throw "Test262: This statement should not be evaluated."; - -var x = "constructor"; -class C { +var x = 'constructor'; +class C1 { static [x]; } + +verifyProperty(C1, 'constructor', { + value: undefined, + configurable: true, + writable: true, + enumerable: true, +}); + +class C2 { + static [x] = 42; +} + +verifyProperty(C2, 'constructor', { + value: 42, + configurable: true, + writable: true, + enumerable: true, +}); diff --git a/test/language/statements/class/fields-computed-name-static-computed-var-propname-prototype.js b/test/language/statements/class/fields-computed-name-static-computed-var-propname-prototype.js index 4186915a5f..6d46a56f28 100644 --- a/test/language/statements/class/fields-computed-name-static-computed-var-propname-prototype.js +++ b/test/language/statements/class/fields-computed-name-static-computed-var-propname-prototype.js @@ -1,31 +1,32 @@ // Copyright (C) 2017 Valerie Young. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: static class fields forbid PropName 'prototype' (no early error -- PropName of ComputedPropertyName not forbidden value) +description: static class fields forbid PropName 'prototype' (no early error -- PropName of ComputedPropertyName) esid: sec-class-definitions-static-semantics-early-errors features: [class, class-static-fields-public] info: | - Static Semantics: PropName - ... - ComputedPropertyName : [ AssignmentExpression ] - Return empty. + 14.6.13 Runtime Semantics: ClassDefinitionEvaluation + ... + 16. Perform MakeConstructor(F, false, proto). + ... - // This test file tests the following early error: - Static Semantics: Early Errors - - ClassElement : static FieldDefinition; - It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". - -negative: - phase: parse - type: SyntaxError + 9.2.10 MakeConstructor ( F [ , writablePrototype [ , prototype ] ] ) + 6. Perform ! DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]: prototype, + [[Writable]]: writablePrototype, [[Enumerable]]: false, [[Configurable]]: false }). ---*/ -throw "Test262: This statement should not be evaluated."; - var x = "prototype"; -class C { - static [x]; -} + +assert.throws(TypeError, function() { + class C { + static [x] = 42; + } +}); + +assert.throws(TypeError, function() { + class C { + static [x]; + } +}); diff --git a/test/language/statements/class/fields-computed-name-static-propname-constructor.js b/test/language/statements/class/fields-computed-name-static-propname-constructor.js index 218a01bfe5..0f5689a57e 100644 --- a/test/language/statements/class/fields-computed-name-static-propname-constructor.js +++ b/test/language/statements/class/fields-computed-name-static-propname-constructor.js @@ -1,30 +1,79 @@ -// Copyright (C) 2017 Valerie Young. All rights reserved. +// Copyright (C) 2017 Leo Balter. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: static class fields forbid PropName 'prototype' (no early error -- PropName of ComputedPropertyName not forbidden value) +description: static class fields forbid PropName 'constructor' (no early error -- PropName of ComputedPropertyName not forbidden value) esid: sec-class-definitions-static-semantics-early-errors -features: [class-static-fields-public] +features: [class, class-static-fields-public] info: | Static Semantics: PropName ... ComputedPropertyName : [ AssignmentExpression ] Return empty. + This test file tests the following early error is only valid for a matching PropName: - // This test file tests the following early error: Static Semantics: Early Errors - ClassElement : static FieldDefinition; + ClassElement : static FieldDefinition; It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". -negative: - phase: parse - type: SyntaxError + -- IDK what is calling InitializeClassElements but I guess it's supposed to be called to + -- set the fields + InitializeClassElements(F, proto) + + ... + 6. For each item element in order from elements, + a. If element.[[Kind]] is "field" and element.[[Placement]] is "static" or "prototype", + ... + ii. Let receiver be F if element.[[Placement]] is "static", else let receiver be proto. + iii. Perform ? DefineClassElement(receiver, element). + + -- DefineClassElement is probably DefineField in the class fields proposal + + DefineField(receiver, fieldRecord) + + ... + 8. If fieldName is a Private Name, + ... + 9. Else, + a. ... + b. Perform ? CreateDataPropertyOrThrow(receiver, fieldName, initValue). + + CreateDataPropertyOrThrow ( O, P, V ) + + ... + 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). +includes: [propertyHelper.js] ---*/ -throw "Test262: This statement should not be evaluated."; - -class C { - static ["constructor"]; +class C1 { + static ['constructor']; } + +verifyProperty(C1, 'constructor', { + value: undefined, + configurable: true, + writable: true, + enumerable: true, +}); + +class C2 { + static ['constructor'] = 42; +} + +verifyProperty(C2, 'constructor', { + value: 42, + configurable: true, + writable: true, + enumerable: true, +}); diff --git a/test/language/statements/class/fields-computed-name-static-propname-prototype.js b/test/language/statements/class/fields-computed-name-static-propname-prototype.js index 32e416a369..0444215278 100644 --- a/test/language/statements/class/fields-computed-name-static-propname-prototype.js +++ b/test/language/statements/class/fields-computed-name-static-propname-prototype.js @@ -1,30 +1,30 @@ // Copyright (C) 2017 Valerie Young. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -description: static class fields forbid PropName 'prototype' (no early error -- PropName of ComputedPropertyName not forbidden value) +description: static class fields forbid PropName 'prototype' (no early error -- PropName of ComputedPropertyName) esid: sec-class-definitions-static-semantics-early-errors -features: [class-static-fields-public] +features: [class, class-static-fields-public] info: | - Static Semantics: PropName - ... - ComputedPropertyName : [ AssignmentExpression ] - Return empty. + 14.6.13 Runtime Semantics: ClassDefinitionEvaluation + ... + 16. Perform MakeConstructor(F, false, proto). + ... - // This test file tests the following early error: - Static Semantics: Early Errors - - ClassElement : static FieldDefinition; - It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". - -negative: - phase: parse - type: SyntaxError + 9.2.10 MakeConstructor ( F [ , writablePrototype [ , prototype ] ] ) + 6. Perform ! DefinePropertyOrThrow(F, "prototype", PropertyDescriptor { [[Value]]: prototype, + [[Writable]]: writablePrototype, [[Enumerable]]: false, [[Configurable]]: false }). ---*/ -throw "Test262: This statement should not be evaluated."; +assert.throws(TypeError, function() { + class C { + static ['prototype'] = 42; + } +}); -class C { - static ["prototype"]; -} +assert.throws(TypeError, function() { + class C { + static ['prototype']; + } +}); diff --git a/test/language/statements/class/fields-computed-name-toprimitive-symbol.js b/test/language/statements/class/fields-computed-name-toprimitive-symbol.js index 8818450017..b68841fce4 100644 --- a/test/language/statements/class/fields-computed-name-toprimitive-symbol.js +++ b/test/language/statements/class/fields-computed-name-toprimitive-symbol.js @@ -62,8 +62,6 @@ var obj3 = { valueOf: function() { return s3; } }; - - class C { [obj1] = 42; [obj2] = 43;