From e25e53c0a74e5988b48d02275367af3e67ece9d8 Mon Sep 17 00:00:00 2001 From: Leo Balter <leonardo.balter@gmail.com> Date: Tue, 21 Aug 2018 16:11:27 -0400 Subject: [PATCH] Fix tests for #constructor --- ...fields-hash-constructor-is-a-valid-name.js | 40 +++++++++++++++++++ ...fields-string-name-propname-constructor.js | 22 ---------- 2 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 test/language/statements/class/fields-hash-constructor-is-a-valid-name.js delete mode 100644 test/language/statements/class/privatefields-string-name-propname-constructor.js diff --git a/test/language/statements/class/fields-hash-constructor-is-a-valid-name.js b/test/language/statements/class/fields-hash-constructor-is-a-valid-name.js new file mode 100644 index 0000000000..6311234f7d --- /dev/null +++ b/test/language/statements/class/fields-hash-constructor-is-a-valid-name.js @@ -0,0 +1,40 @@ +// Copyright (C) 2018 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: "#constructor is a valid property name for a public field" +esid: sec-class-definitions-static-semantics-early-errors +features: [class, class-fields-public] +info: | + ClassElementName : PrivateName; + + It is a Syntax Error if StringValue of PrivateName is "#constructor". +includes: [propertyHelper.js] +---*/ + +class C1 { + ["#constructor"]; +} + +var c1 = new C1(); + +assert.sameValue(Object.prototype.hasOwnProperty.call(C1, '#constructor'), false); +verifyProperty(c1, '#constructor', { + value: undefined, + configurable: true, + enumerable: true, + writable: true, +}); + +class C2 { + ["#constructor"] = 42; +} + +var c2 = new C2(); + +assert.sameValue(Object.prototype.hasOwnProperty.call(C2, '#constructor'), false); +verifyProperty(c2, '#constructor', { + value: 42, + configurable: true, + enumerable: true, + writable: true, +}); diff --git a/test/language/statements/class/privatefields-string-name-propname-constructor.js b/test/language/statements/class/privatefields-string-name-propname-constructor.js deleted file mode 100644 index ab0700a5fc..0000000000 --- a/test/language/statements/class/privatefields-string-name-propname-constructor.js +++ /dev/null @@ -1,22 +0,0 @@ -// 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' (early error -- PropName of StringLiteral is forbidden value) -esid: sec-class-definitions-static-semantics-early-errors -features: [class, class-fields-private] -negative: - phase: parse - type: SyntaxError -info: | - ClassElementName : PrivateName; - - It is a Syntax Error if StringValue of PrivateName is "#constructor". - ----*/ - - -throw "Test262: This statement should not be evaluated."; - -class C { - ["#constructor"]; -} -- GitLab