diff --git a/test/language/expressions/class/fields-after-same-line-gen-computed-names.js b/test/language/expressions/class/fields-after-same-line-gen-computed-names.js index 689a4f816726b144454982d770887e6e6dcbad57..4b69ab918df5f4ca20d8bdb04f338858b7b03bb2 100644 --- a/test/language/expressions/class/fields-after-same-line-gen-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-gen-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; var C = class { *m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-gen-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-gen-computed-symbol-names.js index 0b66155c2d390116780eb593cfcb5a76bcbfe153..04b88ace7bedebb417a75291e82b60f9748cdf22 100644 --- a/test/language/expressions/class/fields-after-same-line-gen-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-gen-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-gen-literal-names.js b/test/language/expressions/class/fields-after-same-line-gen-literal-names.js index 594773b5967ec7b186bb18dc34dd3e772347212c..31bfb6475166e5c81a3060b6c55bd55d0e08a7a6 100644 --- a/test/language/expressions/class/fields-after-same-line-gen-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-gen-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { *m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-gen-private-names.js b/test/language/expressions/class/fields-after-same-line-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..ffaa9a3ce7408ed4a4eda98896a5130e90ef3f30 --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-gen-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-after-same-line-gen.template +/*--- +description: static literal private names (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [generators, class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + *m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-after-same-line-gen-static-computed-names.js b/test/language/expressions/class/fields-after-same-line-gen-static-computed-names.js index 84f29734cc45295bcdca7db7303a8b3c3f918efa..950cde0b7df8576b76d993b30b023440efdc2e69 100644 --- a/test/language/expressions/class/fields-after-same-line-gen-static-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-gen-static-computed-names.js @@ -24,6 +24,7 @@ info: | var C = class { *m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-gen-static-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-gen-static-computed-symbol-names.js index dff0f916d5f9c0e464431b5ecdc66b058311865a..862006eb8c00a0d3be8d3d5f2a48e680a37a5c55 100644 --- a/test/language/expressions/class/fields-after-same-line-gen-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-gen-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-gen-static-literal-names.js b/test/language/expressions/class/fields-after-same-line-gen-static-literal-names.js index 82ad2348d3a1fc8df4ad82120defb05b60b8fa7c..8c142d28dc690c1d528d3b4b6a1a4bd0b652e13e 100644 --- a/test/language/expressions/class/fields-after-same-line-gen-static-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-gen-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { *m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-gen-static-private-names.js b/test/language/expressions/class/fields-after-same-line-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..4c34ca6a247353106e7071cb9a62e2ccf74eccaa --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-gen-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-after-same-line-gen.template +/*--- +description: literal private names (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [generators, class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + *m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-after-same-line-gen-string-literal-names.js b/test/language/expressions/class/fields-after-same-line-gen-string-literal-names.js index 702d11f6c7e201c30e8547538d8611ecc124e378..83f0e3000c4544168c488192f0e1de174bc6d1a4 100644 --- a/test/language/expressions/class/fields-after-same-line-gen-string-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-gen-string-literal-names.js @@ -24,6 +24,7 @@ info: | var C = class { *m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-method-computed-names.js b/test/language/expressions/class/fields-after-same-line-method-computed-names.js index 9ea365d415e7c4b08c7c04e5a92defee68620cd6..315dbf91fcc71256f48705d4871ecfaab22f30ab 100644 --- a/test/language/expressions/class/fields-after-same-line-method-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-method-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; var C = class { m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-method-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-method-computed-symbol-names.js index 78cf52e3891986695f4392f41fb7b03fc97962c1..59fcfd8a8c884963e4a14d0014a6c8287844b2e0 100644 --- a/test/language/expressions/class/fields-after-same-line-method-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-method-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-method-literal-names.js b/test/language/expressions/class/fields-after-same-line-method-literal-names.js index 86eb9b5794d4653d96d66d27aea34c77962e61eb..a41dd10ec5ee94fb2e38c745fabdf545a1dd5359 100644 --- a/test/language/expressions/class/fields-after-same-line-method-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-method-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-method-private-names.js b/test/language/expressions/class/fields-after-same-line-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..36f3fb297eb4a79083d4c9d93aa636789891f378 --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-method-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-after-same-line-method.template +/*--- +description: static literal private names (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-after-same-line-method-static-computed-names.js b/test/language/expressions/class/fields-after-same-line-method-static-computed-names.js index b28a11e2ee52a6d73c179e0de42c79ff3082dee9..a7b45b5fd516b9fce7160c1dd88763af12691488 100644 --- a/test/language/expressions/class/fields-after-same-line-method-static-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-method-static-computed-names.js @@ -24,6 +24,7 @@ info: | var C = class { m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-method-static-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-method-static-computed-symbol-names.js index bfe62d6b9ef2b73811cbb86c9148d8e7bee0e5bd..9bc01fb70b1451e70115404dd9a969578b05cd2e 100644 --- a/test/language/expressions/class/fields-after-same-line-method-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-method-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-method-static-literal-names.js b/test/language/expressions/class/fields-after-same-line-method-static-literal-names.js index 4767ff8947e6eb169c94041b5011923d635dfd7d..53a57334919fbda52ffc6ad4d1b242596f86ce14 100644 --- a/test/language/expressions/class/fields-after-same-line-method-static-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-method-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-method-static-private-names.js b/test/language/expressions/class/fields-after-same-line-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..3a382f7304071289dda2faf37f8b9ad84e1b0580 --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-method-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-after-same-line-method.template +/*--- +description: literal private names (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-after-same-line-method-string-literal-names.js b/test/language/expressions/class/fields-after-same-line-method-string-literal-names.js index 4f393da149749686359f20e2bc1a610e1181d469..4299b5e82383c00711eaf958ff6729671ea40d74 100644 --- a/test/language/expressions/class/fields-after-same-line-method-string-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-method-string-literal-names.js @@ -24,6 +24,7 @@ info: | var C = class { m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-gen-computed-names.js b/test/language/expressions/class/fields-after-same-line-static-async-gen-computed-names.js index bf8a4bdeb9aada0bf3746c62f33fe80644a59085..19c7a83737d6b7a97ef795c4e3d97245f599062a 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-gen-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-gen-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; var C = class { static async *m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-gen-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-static-async-gen-computed-symbol-names.js index 6bb1f5608949c9e2b28c7988beaca31e4bdb8f0d..83fd381d86d831d99e00559b774d9451b532cd8b 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-gen-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-gen-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { static async *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-gen-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-async-gen-literal-names.js index 1fb3501f8d64a74203580c10c2f10bb75b34ae9a..140c82b712709897b09712bcd04873deae3056f7 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-gen-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-gen-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { static async *m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-gen-private-names.js b/test/language/expressions/class/fields-after-same-line-static-async-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..24af08bea32e99b5420f092b188879c32b27b778 --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-static-async-gen-private-names.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-after-same-line-static-async-gen.template +/*--- +description: static literal private names (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-iteration] +flags: [generated, async] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static async *m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-gen-static-computed-names.js b/test/language/expressions/class/fields-after-same-line-static-async-gen-static-computed-names.js index ad0b5b741cce87b35b0f82ced68a056bdb4e59e8..f82df5a61e714311cf26c9af63c542f62b8cce54 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-gen-static-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-gen-static-computed-names.js @@ -24,6 +24,7 @@ info: | var C = class { static async *m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-gen-static-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-static-async-gen-static-computed-symbol-names.js index 8946ee477bc9576402e4fbaf943a22c31484fb05..c2ee765339cf3bf0f6c890833ccc0fe8e6012925 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-gen-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-gen-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { static async *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-gen-static-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-async-gen-static-literal-names.js index 62524d9b0f23b3e6bd27dd7a950323c0b3bf59c8..5abb238d56b3c3c1baf8dce8eb120a2baebbaf26 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-gen-static-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-gen-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { static async *m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-gen-static-private-names.js b/test/language/expressions/class/fields-after-same-line-static-async-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..70a7fbfe0aa5fb36ca78041c87a3c2bae4ce69f1 --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-static-async-gen-static-private-names.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-after-same-line-static-async-gen.template +/*--- +description: literal private names (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-iteration] +flags: [generated, async] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static async *m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-gen-string-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-async-gen-string-literal-names.js index bb42ef8fcafba0a9bd7fea81c62c7027c20cee73..6a8912fd795539bef145a85b4b87fef336ce5c5e 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-gen-string-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-gen-string-literal-names.js @@ -24,6 +24,7 @@ info: | var C = class { static async *m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-method-computed-names.js b/test/language/expressions/class/fields-after-same-line-static-async-method-computed-names.js index 5f1fff697d3e28aebb472fb2ee6aee5f64696a5e..e752e8b78b832a8c3998fea741511bd0baf497fc 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-method-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-method-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; var C = class { static async m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-method-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-static-async-method-computed-symbol-names.js index 071c3e4e1a3f2475a9ff42d2bd769b4eb6c5b532..3c844018871442f4a4a1229771a7ed2e089d8354 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-method-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-method-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { static async m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-method-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-async-method-literal-names.js index f2a3391cfc2e87d94dc86b45c31341c72f09fa49..e3c2aa56d9c358567b571e1e9162b2e4b963954a 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-method-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-method-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { static async m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-method-private-names.js b/test/language/expressions/class/fields-after-same-line-static-async-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..fc503358f1bb1e5f0807667261e039ab0a5f47b3 --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-static-async-method-private-names.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-after-same-line-static-async-method.template +/*--- +description: static literal private names (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-functions] +flags: [generated, async] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static async m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); + +C.m().then(function(v) { + assert.sameValue(v, 42); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-method-static-computed-names.js b/test/language/expressions/class/fields-after-same-line-static-async-method-static-computed-names.js index a89010e654aaa5fbac9b7e6d74578c61efb16da4..22f43ebd346ed4969e96cd316aa1ab59f8dcf0b6 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-method-static-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-method-static-computed-names.js @@ -24,6 +24,7 @@ info: | var C = class { static async m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-method-static-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-static-async-method-static-computed-symbol-names.js index 4a0983ac61c213d03d9ed8e28db1642c3ed8dee1..6f560a3b113e14a9663c615ef91351a6545cdea5 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-method-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-method-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { static async m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-method-static-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-async-method-static-literal-names.js index c02d0b1f9c89f36e24f5458af2898fb18ff201f0..698af044bd1e80d3ec937a3632fd28eefcd5aeec 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-method-static-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-method-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { static async m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-method-static-private-names.js b/test/language/expressions/class/fields-after-same-line-static-async-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..9f003c5a79af37566b81868f08f2302971581bfd --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-static-async-method-static-private-names.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-after-same-line-static-async-method.template +/*--- +description: literal private names (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-functions] +flags: [generated, async] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static async m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); + +C.m().then(function(v) { + assert.sameValue(v, 42); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/expressions/class/fields-after-same-line-static-async-method-string-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-async-method-string-literal-names.js index 1503ccc53075053c7c84a8107c5f1755dca78dbb..91b742b2fff984715ac3c35ae425eca998785a2b 100644 --- a/test/language/expressions/class/fields-after-same-line-static-async-method-string-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-async-method-string-literal-names.js @@ -24,6 +24,7 @@ info: | var C = class { static async m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-gen-computed-names.js b/test/language/expressions/class/fields-after-same-line-static-gen-computed-names.js index e2cdc91e97225acd6659fa3533a4bc70d5f93afe..d5998b97b466eb59310d268c2fd09705de91a394 100644 --- a/test/language/expressions/class/fields-after-same-line-static-gen-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-gen-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; var C = class { static *m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-gen-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-static-gen-computed-symbol-names.js index 82b909edb31f4fa410da037decb22303f2a1dbb3..61d79d1619950c2ce73b5b5b253dcb5d37a22bcf 100644 --- a/test/language/expressions/class/fields-after-same-line-static-gen-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-gen-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { static *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-gen-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-gen-literal-names.js index 81084ac8eb6933a64954bfdcad4d779fc3ad86f3..2211245759ff9b51fbb81fea011ef932720bd0ec 100644 --- a/test/language/expressions/class/fields-after-same-line-static-gen-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-gen-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { static *m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-gen-private-names.js b/test/language/expressions/class/fields-after-same-line-static-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..cda34230e4be080a824f3b1aff6c878638c64559 --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-static-gen-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-after-same-line-static-gen.template +/*--- +description: static literal private names (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [generators, class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static *m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-after-same-line-static-gen-static-computed-names.js b/test/language/expressions/class/fields-after-same-line-static-gen-static-computed-names.js index 7995c9c4d0b38793b192b539b3a9b0a0d7e17839..afc668405064cb5601658d66039843592a1912bd 100644 --- a/test/language/expressions/class/fields-after-same-line-static-gen-static-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-gen-static-computed-names.js @@ -24,6 +24,7 @@ info: | var C = class { static *m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-gen-static-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-static-gen-static-computed-symbol-names.js index ddfe132f174d3a272f5209411f0d466f6334e5a3..352e67427724bf09a6e7175c3c122cb5fcad567c 100644 --- a/test/language/expressions/class/fields-after-same-line-static-gen-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-gen-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { static *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-gen-static-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-gen-static-literal-names.js index 184d8ad792ccd9fe088c26edfe53fc9a37f2ed80..f399ad676c584b788df88fc6bd36014a45a4bb70 100644 --- a/test/language/expressions/class/fields-after-same-line-static-gen-static-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-gen-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { static *m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-gen-static-private-names.js b/test/language/expressions/class/fields-after-same-line-static-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..3737195c3e975929df11a712c46496548c3bd379 --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-static-gen-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-after-same-line-static-gen.template +/*--- +description: literal private names (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [generators, class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static *m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-after-same-line-static-gen-string-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-gen-string-literal-names.js index 871c99f054dbb1472fc8a6707e752c563345fce2..9e97ccb68a5246f9c5e4285a78b11f6a2bff43d0 100644 --- a/test/language/expressions/class/fields-after-same-line-static-gen-string-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-gen-string-literal-names.js @@ -24,6 +24,7 @@ info: | var C = class { static *m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-method-computed-names.js b/test/language/expressions/class/fields-after-same-line-static-method-computed-names.js index a941be27e56f6186b1a8d7f057743920bfe15b50..63a43adc8111ea27c4a77ff4a330e1cfb019188b 100644 --- a/test/language/expressions/class/fields-after-same-line-static-method-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-method-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; var C = class { static m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-method-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-static-method-computed-symbol-names.js index 1eebc6280a5e23360a0940cc5a0e1e3852d379fa..7c55fa75614eda4d1e6f694177b9df9e7e64fec5 100644 --- a/test/language/expressions/class/fields-after-same-line-static-method-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-method-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { static m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-method-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-method-literal-names.js index 2019767e1e2ceefca3730076d9cbd9f446d6998f..2dde2d09c1864db7fdbe8b0807089968152250ee 100644 --- a/test/language/expressions/class/fields-after-same-line-static-method-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-method-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { static m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-method-private-names.js b/test/language/expressions/class/fields-after-same-line-static-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..2e8fecf2220c2a1e0b03ec610670591bfcf028aa --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-static-method-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-after-same-line-static-method.template +/*--- +description: static literal private names (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-after-same-line-static-method-static-computed-names.js b/test/language/expressions/class/fields-after-same-line-static-method-static-computed-names.js index d4606dca5b4cb8b1312f148c98703003ed996e53..b307989ef26e4607717004a3e6b494e2775317a3 100644 --- a/test/language/expressions/class/fields-after-same-line-static-method-static-computed-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-method-static-computed-names.js @@ -24,6 +24,7 @@ info: | var C = class { static m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-method-static-computed-symbol-names.js b/test/language/expressions/class/fields-after-same-line-static-method-static-computed-symbol-names.js index b24c07b5a6a3460707ac00bd55a4d6a4451ce224..cc85063ea9e5a2660cc1ee784ed69b382fba32e5 100644 --- a/test/language/expressions/class/fields-after-same-line-static-method-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-method-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { static m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-method-static-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-method-static-literal-names.js index 145ebc858b77dbcd9fbb197e740341e3ee6d64b6..0dc301af6e4b20aeebbd5117897c211740ae2214 100644 --- a/test/language/expressions/class/fields-after-same-line-static-method-static-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-method-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { static m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-after-same-line-static-method-static-private-names.js b/test/language/expressions/class/fields-after-same-line-static-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..35ff7f11f534648170f4967b97797646ec949a84 --- /dev/null +++ b/test/language/expressions/class/fields-after-same-line-static-method-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-after-same-line-static-method.template +/*--- +description: literal private names (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-after-same-line-static-method-string-literal-names.js b/test/language/expressions/class/fields-after-same-line-static-method-string-literal-names.js index 912d3fd84261d7eb7a70feee6edf762115c851bf..9478ba20141278cf4ad718b661f03cc2bde02d14 100644 --- a/test/language/expressions/class/fields-after-same-line-static-method-string-literal-names.js +++ b/test/language/expressions/class/fields-after-same-line-static-method-string-literal-names.js @@ -24,6 +24,7 @@ info: | var C = class { static m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-definitions-computed-names.js b/test/language/expressions/class/fields-multiple-definitions-computed-names.js index 416ad8c13bf4413a7145a0585dfb61aae612af4c..610be4d561538a43c38c3156d4955942f933b306 100644 --- a/test/language/expressions/class/fields-multiple-definitions-computed-names.js +++ b/test/language/expressions/class/fields-multiple-definitions-computed-names.js @@ -29,6 +29,7 @@ var C = class { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"] m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-definitions-computed-symbol-names.js b/test/language/expressions/class/fields-multiple-definitions-computed-symbol-names.js index 8519a7ca2232c6e448ae640b858e76d8071d27bb..fe316fa7673b2702a571d42144c985b0b0671525 100644 --- a/test/language/expressions/class/fields-multiple-definitions-computed-symbol-names.js +++ b/test/language/expressions/class/fields-multiple-definitions-computed-symbol-names.js @@ -30,6 +30,7 @@ var C = class { [x]; [y] = 42 m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-definitions-literal-names.js b/test/language/expressions/class/fields-multiple-definitions-literal-names.js index 363a59ef61660846cbc55b64bb57ee404c3f0649..efe198d20a71627377ed0f974c299ec64b229d3e 100644 --- a/test/language/expressions/class/fields-multiple-definitions-literal-names.js +++ b/test/language/expressions/class/fields-multiple-definitions-literal-names.js @@ -30,6 +30,7 @@ var C = class { c = fn m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-definitions-private-names.js b/test/language/expressions/class/fields-multiple-definitions-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..24c1a7f4d33b5849fe6884182ab5dbbe641c96de --- /dev/null +++ b/test/language/expressions/class/fields-multiple-definitions-private-names.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-multiple-definitions.template +/*--- +description: static literal private names (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + foo = "foobar"; + m() { return 42 } + #x; #y + m2() { return 39 } + bar = "barbaz"; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert.sameValue(Object.hasOwnProperty.call(c, "m2"), false); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert.sameValue(Object.hasOwnProperty.call(C, "foo"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "foo"), false); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert.sameValue(Object.hasOwnProperty.call(C, "bar"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "bar"), false); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-multiple-definitions-static-computed-names.js b/test/language/expressions/class/fields-multiple-definitions-static-computed-names.js index 8cad37f657d76dff5ad6306f05d1459a7183a91d..2666dbfbbf2a053de85caa280335bb569fb888a5 100644 --- a/test/language/expressions/class/fields-multiple-definitions-static-computed-names.js +++ b/test/language/expressions/class/fields-multiple-definitions-static-computed-names.js @@ -28,6 +28,7 @@ var C = class { static ["a"] = 42; ["a"] = 39 m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-definitions-static-computed-symbol-names.js b/test/language/expressions/class/fields-multiple-definitions-static-computed-symbol-names.js index 532e33e6fe165ac138f00b562a9c5c4cca0a8361..fad1bd2be687d3b687893d6c82eb6e4811e61af9 100644 --- a/test/language/expressions/class/fields-multiple-definitions-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-multiple-definitions-static-computed-symbol-names.js @@ -30,6 +30,7 @@ var C = class { [x]; [y] = 42 m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-definitions-static-literal-names.js b/test/language/expressions/class/fields-multiple-definitions-static-literal-names.js index 41582a4765999baaba04c3d2ea310eccd7375eac..2a99b9ceeb322d631882e28ac194122230f21630 100644 --- a/test/language/expressions/class/fields-multiple-definitions-static-literal-names.js +++ b/test/language/expressions/class/fields-multiple-definitions-static-literal-names.js @@ -30,6 +30,7 @@ var C = class { static c = fn m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-definitions-static-private-names.js b/test/language/expressions/class/fields-multiple-definitions-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..c501bd1184c5b39a8638005e6c2bfc826cbdd260 --- /dev/null +++ b/test/language/expressions/class/fields-multiple-definitions-static-private-names.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-multiple-definitions.template +/*--- +description: literal private names (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + foo = "foobar"; + m() { return 42 } + static #x; static #y + m2() { return 39 } + bar = "barbaz"; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert.sameValue(Object.hasOwnProperty.call(c, "m2"), false); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert.sameValue(Object.hasOwnProperty.call(C, "foo"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "foo"), false); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert.sameValue(Object.hasOwnProperty.call(C, "bar"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "bar"), false); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-multiple-definitions-string-literal-names.js b/test/language/expressions/class/fields-multiple-definitions-string-literal-names.js index 01d14e554894dc211bb2007c2f8a8457d2cf892d..a13a44c26c797a217542fa5830d0da0f576aea26 100644 --- a/test/language/expressions/class/fields-multiple-definitions-string-literal-names.js +++ b/test/language/expressions/class/fields-multiple-definitions-string-literal-names.js @@ -28,6 +28,7 @@ var C = class { "d" = 42 m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-stacked-definitions-computed-names.js b/test/language/expressions/class/fields-multiple-stacked-definitions-computed-names.js index 5edb040779705c2b5e32f65af979973bbd9960e9..3271e38e3ca92589d44c2ad1040fc65a0b620960 100644 --- a/test/language/expressions/class/fields-multiple-stacked-definitions-computed-names.js +++ b/test/language/expressions/class/fields-multiple-stacked-definitions-computed-names.js @@ -27,6 +27,7 @@ var C = class { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"] foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-stacked-definitions-computed-symbol-names.js b/test/language/expressions/class/fields-multiple-stacked-definitions-computed-symbol-names.js index ebfb312d389be35738513f994a0fed82a6aa9ad6..e9d610605ce4d8775ff700d2226704f2dedee39a 100644 --- a/test/language/expressions/class/fields-multiple-stacked-definitions-computed-symbol-names.js +++ b/test/language/expressions/class/fields-multiple-stacked-definitions-computed-symbol-names.js @@ -28,6 +28,7 @@ var C = class { [x]; [y] = 42 foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-stacked-definitions-literal-names.js b/test/language/expressions/class/fields-multiple-stacked-definitions-literal-names.js index b03279776e6969de5c26ca7ff708f7ee5a576530..71f21a5f88f0e847928c35345746794f2f1a6768 100644 --- a/test/language/expressions/class/fields-multiple-stacked-definitions-literal-names.js +++ b/test/language/expressions/class/fields-multiple-stacked-definitions-literal-names.js @@ -28,6 +28,7 @@ var C = class { c = fn foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-stacked-definitions-private-names.js b/test/language/expressions/class/fields-multiple-stacked-definitions-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..543a968bbbfc8a1546aa34751cc94509be0297ea --- /dev/null +++ b/test/language/expressions/class/fields-multiple-stacked-definitions-private-names.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-multiple-stacked-definitions.template +/*--- +description: static literal private names (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + #x; #y + foo = "foobar" + bar = "barbaz"; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert.sameValue(Object.hasOwnProperty.call(C, "foo"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "foo"), false); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert.sameValue(Object.hasOwnProperty.call(C, "bar"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "bar"), false); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-multiple-stacked-definitions-static-computed-names.js b/test/language/expressions/class/fields-multiple-stacked-definitions-static-computed-names.js index d41fc55b61f8d6dd068c60cd53fbc9bfd5dab733..b33aabe33425746eae33e44289ac9d158bc0aab7 100644 --- a/test/language/expressions/class/fields-multiple-stacked-definitions-static-computed-names.js +++ b/test/language/expressions/class/fields-multiple-stacked-definitions-static-computed-names.js @@ -26,6 +26,7 @@ var C = class { static ["a"] = 42; ["a"] = 39 foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-stacked-definitions-static-computed-symbol-names.js b/test/language/expressions/class/fields-multiple-stacked-definitions-static-computed-symbol-names.js index c4ae11ed6fb66f36b2c41989c6f4c7d09e4e4df0..ed8e6280b35f7bc31bcba0f4d2cda8318de68e8e 100644 --- a/test/language/expressions/class/fields-multiple-stacked-definitions-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-multiple-stacked-definitions-static-computed-symbol-names.js @@ -28,6 +28,7 @@ var C = class { [x]; [y] = 42 foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-stacked-definitions-static-literal-names.js b/test/language/expressions/class/fields-multiple-stacked-definitions-static-literal-names.js index 36dd4190a0f2f9833f07ae9b8d6c714877fba03c..2c2bcfb46d749d102ff170f3efbf10cef19b0a8a 100644 --- a/test/language/expressions/class/fields-multiple-stacked-definitions-static-literal-names.js +++ b/test/language/expressions/class/fields-multiple-stacked-definitions-static-literal-names.js @@ -28,6 +28,7 @@ var C = class { static c = fn foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-multiple-stacked-definitions-static-private-names.js b/test/language/expressions/class/fields-multiple-stacked-definitions-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..668588fdb13514031ae61580873a541aa546eb12 --- /dev/null +++ b/test/language/expressions/class/fields-multiple-stacked-definitions-static-private-names.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-multiple-stacked-definitions.template +/*--- +description: literal private names (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static #x; static #y + foo = "foobar" + bar = "barbaz"; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert.sameValue(Object.hasOwnProperty.call(C, "foo"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "foo"), false); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert.sameValue(Object.hasOwnProperty.call(C, "bar"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "bar"), false); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-multiple-stacked-definitions-string-literal-names.js b/test/language/expressions/class/fields-multiple-stacked-definitions-string-literal-names.js index 9b21d9a004d64123aa8773fface618f8305ec040..32edf331d772ce1ac4c785b21a33aa5550e201d4 100644 --- a/test/language/expressions/class/fields-multiple-stacked-definitions-string-literal-names.js +++ b/test/language/expressions/class/fields-multiple-stacked-definitions-string-literal-names.js @@ -26,6 +26,7 @@ var C = class { "d" = 42 foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-no-sc-line-method-computed-names.js b/test/language/expressions/class/fields-new-no-sc-line-method-computed-names.js index 7b378eb56a89a2f998a6ea009a2c13a92cbe1bf6..50354308aadd85531a3d24ba30b03c259b12df41 100644 --- a/test/language/expressions/class/fields-new-no-sc-line-method-computed-names.js +++ b/test/language/expressions/class/fields-new-no-sc-line-method-computed-names.js @@ -26,6 +26,7 @@ var x = "b"; var C = class { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"] m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-no-sc-line-method-computed-symbol-names.js b/test/language/expressions/class/fields-new-no-sc-line-method-computed-symbol-names.js index e986e9a250c008430591f5a5df7993661eeb3e95..da7b129ba01c69f0ae6b93f3bc2b4e200d36e151 100644 --- a/test/language/expressions/class/fields-new-no-sc-line-method-computed-symbol-names.js +++ b/test/language/expressions/class/fields-new-no-sc-line-method-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42 m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-no-sc-line-method-literal-names.js b/test/language/expressions/class/fields-new-no-sc-line-method-literal-names.js index 33007a0f15904e53c6f43b14866dbd656abc30cc..6b927da89e827c160efc564e39f67cd071eb0ef1 100644 --- a/test/language/expressions/class/fields-new-no-sc-line-method-literal-names.js +++ b/test/language/expressions/class/fields-new-no-sc-line-method-literal-names.js @@ -27,6 +27,7 @@ var C = class { a; b = 42; c = fn m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-no-sc-line-method-private-names.js b/test/language/expressions/class/fields-new-no-sc-line-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..e9dfb809d03221de18bc7ee50eabf14bb6f598a2 --- /dev/null +++ b/test/language/expressions/class/fields-new-no-sc-line-method-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-new-no-sc-line-method.template +/*--- +description: static literal private names (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + #x; #y + m() { return 42; } +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-new-no-sc-line-method-static-computed-names.js b/test/language/expressions/class/fields-new-no-sc-line-method-static-computed-names.js index 8a3b917eac9247dac979539c8c7a02b93c418033..09d71d21f2f92314b8036563b3013fd719d0e601 100644 --- a/test/language/expressions/class/fields-new-no-sc-line-method-static-computed-names.js +++ b/test/language/expressions/class/fields-new-no-sc-line-method-static-computed-names.js @@ -25,6 +25,7 @@ info: | var C = class { static ["a"] = 42; ["a"] = 39 m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-no-sc-line-method-static-computed-symbol-names.js b/test/language/expressions/class/fields-new-no-sc-line-method-static-computed-symbol-names.js index 661596f15db2df30aa64ef1a2c2e7d5457e17109..c4f818aad13a374d1acc275dcfeff5df4a030711 100644 --- a/test/language/expressions/class/fields-new-no-sc-line-method-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-new-no-sc-line-method-static-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42 m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-no-sc-line-method-static-literal-names.js b/test/language/expressions/class/fields-new-no-sc-line-method-static-literal-names.js index ff5e5d6ecdc517374ffb7fd82f38e19d48408641..7c6b809956b377c86eafad4c91aad3ce48c07246 100644 --- a/test/language/expressions/class/fields-new-no-sc-line-method-static-literal-names.js +++ b/test/language/expressions/class/fields-new-no-sc-line-method-static-literal-names.js @@ -27,6 +27,7 @@ var C = class { static a; b = 42; static c = fn m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-no-sc-line-method-static-private-names.js b/test/language/expressions/class/fields-new-no-sc-line-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..2417c0e0006b51ebe72d956dd1a1f118d98eb40a --- /dev/null +++ b/test/language/expressions/class/fields-new-no-sc-line-method-static-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-new-no-sc-line-method.template +/*--- +description: literal private names (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static #x; static #y + m() { return 42; } +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-new-no-sc-line-method-string-literal-names.js b/test/language/expressions/class/fields-new-no-sc-line-method-string-literal-names.js index bb0f8ad79b8e1d3332983f12f50bcebf574f065b..e79b91f747a00f6703e5cbee2a7a2fda5f477aea 100644 --- a/test/language/expressions/class/fields-new-no-sc-line-method-string-literal-names.js +++ b/test/language/expressions/class/fields-new-no-sc-line-method-string-literal-names.js @@ -25,6 +25,7 @@ var C = class { 'a'; "b"; 'c' = 39; "d" = 42 m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-gen-computed-names.js b/test/language/expressions/class/fields-new-sc-line-gen-computed-names.js index 90ce595755303ebfe7bd8c406a438ddec0bc5795..060487bd3cf07aa0d6d39f1c4ebd827532229833 100644 --- a/test/language/expressions/class/fields-new-sc-line-gen-computed-names.js +++ b/test/language/expressions/class/fields-new-sc-line-gen-computed-names.js @@ -26,6 +26,7 @@ var x = "b"; var C = class { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-gen-computed-symbol-names.js b/test/language/expressions/class/fields-new-sc-line-gen-computed-symbol-names.js index 53ea16561103e4842132d898871f07aebe124b0a..1ea70aa907386cc5b64b448336326c404e1a9ec3 100644 --- a/test/language/expressions/class/fields-new-sc-line-gen-computed-symbol-names.js +++ b/test/language/expressions/class/fields-new-sc-line-gen-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-gen-literal-names.js b/test/language/expressions/class/fields-new-sc-line-gen-literal-names.js index d72b29e1c1d74393dabb1dc77a3386642b76888f..839857733231455305da324858a4aab1711ac5a1 100644 --- a/test/language/expressions/class/fields-new-sc-line-gen-literal-names.js +++ b/test/language/expressions/class/fields-new-sc-line-gen-literal-names.js @@ -27,6 +27,7 @@ var C = class { a; b = 42; c = fn; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-gen-private-names.js b/test/language/expressions/class/fields-new-sc-line-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..2a3a38aafab941a2cdf427ae7d7794d47258dfa1 --- /dev/null +++ b/test/language/expressions/class/fields-new-sc-line-gen-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-new-sc-line-generator.template +/*--- +description: static literal private names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields, generators] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + #x; #y; + *m() { return 42; } +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-new-sc-line-gen-static-computed-names.js b/test/language/expressions/class/fields-new-sc-line-gen-static-computed-names.js index 43aa375b2a1ab19436d059a8f14bd2c4ef67fa86..26e4996cdda6c518fe479fd91037956e993053b2 100644 --- a/test/language/expressions/class/fields-new-sc-line-gen-static-computed-names.js +++ b/test/language/expressions/class/fields-new-sc-line-gen-static-computed-names.js @@ -25,6 +25,7 @@ info: | var C = class { static ["a"] = 42; ["a"] = 39; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-gen-static-computed-symbol-names.js b/test/language/expressions/class/fields-new-sc-line-gen-static-computed-symbol-names.js index 38e09794368be98cdf7e0f10327d166d34ff121f..dadfa266a54d26dc6b7fe0393a541512e82541d3 100644 --- a/test/language/expressions/class/fields-new-sc-line-gen-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-new-sc-line-gen-static-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-gen-static-literal-names.js b/test/language/expressions/class/fields-new-sc-line-gen-static-literal-names.js index 25263cd72660777761d3d6c7eee338d6513e692f..1af95389af13091c23e1270bb6705e54ea21853c 100644 --- a/test/language/expressions/class/fields-new-sc-line-gen-static-literal-names.js +++ b/test/language/expressions/class/fields-new-sc-line-gen-static-literal-names.js @@ -27,6 +27,7 @@ var C = class { static a; b = 42; static c = fn; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-gen-static-private-names.js b/test/language/expressions/class/fields-new-sc-line-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..d3d6df8466d1d2141a185962bcd2b258376dcd58 --- /dev/null +++ b/test/language/expressions/class/fields-new-sc-line-gen-static-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-new-sc-line-generator.template +/*--- +description: literal private names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields, generators] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static #x; static #y; + *m() { return 42; } +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-new-sc-line-gen-string-literal-names.js b/test/language/expressions/class/fields-new-sc-line-gen-string-literal-names.js index a9054101c2388fedbef4df35b0e142df4819116b..ac1db02e5e8940651f144acf2f8f28154d3a05ec 100644 --- a/test/language/expressions/class/fields-new-sc-line-gen-string-literal-names.js +++ b/test/language/expressions/class/fields-new-sc-line-gen-string-literal-names.js @@ -25,6 +25,7 @@ var C = class { 'a'; "b"; 'c' = 39; "d" = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-method-computed-names.js b/test/language/expressions/class/fields-new-sc-line-method-computed-names.js index afb17620df5f2e45cc6fac5b800ab0ca1d06e6c3..0c3f140903b0e3f05800a30f509a93a458001229 100644 --- a/test/language/expressions/class/fields-new-sc-line-method-computed-names.js +++ b/test/language/expressions/class/fields-new-sc-line-method-computed-names.js @@ -26,6 +26,7 @@ var x = "b"; var C = class { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-method-computed-symbol-names.js b/test/language/expressions/class/fields-new-sc-line-method-computed-symbol-names.js index a8c0c3fffedd7ec592cedeb64bb668364a6cc518..c79e78b692faee45f7f12ebbe176d1fb4bbd24fb 100644 --- a/test/language/expressions/class/fields-new-sc-line-method-computed-symbol-names.js +++ b/test/language/expressions/class/fields-new-sc-line-method-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-method-literal-names.js b/test/language/expressions/class/fields-new-sc-line-method-literal-names.js index 3d533ee809ab58d3a113e1eade16a729a95d0027..65211827daa6311470af5e0ee4db9b09a7320f1d 100644 --- a/test/language/expressions/class/fields-new-sc-line-method-literal-names.js +++ b/test/language/expressions/class/fields-new-sc-line-method-literal-names.js @@ -27,6 +27,7 @@ var C = class { a; b = 42; c = fn; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-method-private-names.js b/test/language/expressions/class/fields-new-sc-line-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..ec5a05514ccbb1444a0a47387ab8ff3100a5babf --- /dev/null +++ b/test/language/expressions/class/fields-new-sc-line-method-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-new-sc-line-method.template +/*--- +description: static literal private names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + #x; #y; + m() { return 42; } +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-new-sc-line-method-static-computed-names.js b/test/language/expressions/class/fields-new-sc-line-method-static-computed-names.js index bf2ebf7bca487d87b95112331bc15c828fa67404..bd75e093079230abd82444db0d836a7186907c97 100644 --- a/test/language/expressions/class/fields-new-sc-line-method-static-computed-names.js +++ b/test/language/expressions/class/fields-new-sc-line-method-static-computed-names.js @@ -25,6 +25,7 @@ info: | var C = class { static ["a"] = 42; ["a"] = 39; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-method-static-computed-symbol-names.js b/test/language/expressions/class/fields-new-sc-line-method-static-computed-symbol-names.js index 195d9ff0072ca6bec53e2d491023ec1fca42bd52..13884286ad3581fab93a4e7387bc2fb2f84ecb8c 100644 --- a/test/language/expressions/class/fields-new-sc-line-method-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-new-sc-line-method-static-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-method-static-literal-names.js b/test/language/expressions/class/fields-new-sc-line-method-static-literal-names.js index 0b5766c6d3b9b5bbd01a6f59a2301762ab7eeddb..bd1f8e580fcfe99bdb49388b3bf7b6a029f671bc 100644 --- a/test/language/expressions/class/fields-new-sc-line-method-static-literal-names.js +++ b/test/language/expressions/class/fields-new-sc-line-method-static-literal-names.js @@ -27,6 +27,7 @@ var C = class { static a; b = 42; static c = fn; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-new-sc-line-method-static-private-names.js b/test/language/expressions/class/fields-new-sc-line-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..db772d9cb5e1ee3bc65a5828571f125b30d5db07 --- /dev/null +++ b/test/language/expressions/class/fields-new-sc-line-method-static-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-new-sc-line-method.template +/*--- +description: literal private names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static #x; static #y; + m() { return 42; } +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-new-sc-line-method-string-literal-names.js b/test/language/expressions/class/fields-new-sc-line-method-string-literal-names.js index e48c11bbd0d10b9d0c3813eda51ebb7e41a0833c..4848372bc75af262f3135671a2e25a3d075071fd 100644 --- a/test/language/expressions/class/fields-new-sc-line-method-string-literal-names.js +++ b/test/language/expressions/class/fields-new-sc-line-method-string-literal-names.js @@ -25,6 +25,7 @@ var C = class { 'a'; "b"; 'c' = 39; "d" = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-regular-definitions-computed-names.js b/test/language/expressions/class/fields-regular-definitions-computed-names.js index 2cc6d56d4ce56b8b384667390bc7bf406d201389..746b198020d106d60bcba8114602cd30d6513b76 100644 --- a/test/language/expressions/class/fields-regular-definitions-computed-names.js +++ b/test/language/expressions/class/fields-regular-definitions-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; var C = class { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"] + } var c = new C(); diff --git a/test/language/expressions/class/fields-regular-definitions-computed-symbol-names.js b/test/language/expressions/class/fields-regular-definitions-computed-symbol-names.js index f01646bcd4b5005cbda2629cdc2f3fb92353545a..f9b39e52f58d420a05dd66e0e21d9773104651f3 100644 --- a/test/language/expressions/class/fields-regular-definitions-computed-symbol-names.js +++ b/test/language/expressions/class/fields-regular-definitions-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42 + } var c = new C(); diff --git a/test/language/expressions/class/fields-regular-definitions-literal-names.js b/test/language/expressions/class/fields-regular-definitions-literal-names.js index 16f2cd297d401f374c3813fb701225a32c0ed752..e88342eee2c28fd0f600ce00ac9df6d6b2fbb017 100644 --- a/test/language/expressions/class/fields-regular-definitions-literal-names.js +++ b/test/language/expressions/class/fields-regular-definitions-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { a; b = 42; c = fn + } var c = new C(); diff --git a/test/language/expressions/class/fields-regular-definitions-private-names.js b/test/language/expressions/class/fields-regular-definitions-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..820c580a80f5542503940cebe7e72b9dcc8aebae --- /dev/null +++ b/test/language/expressions/class/fields-regular-definitions-private-names.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-regular-definitions.template +/*--- +description: static literal private names (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + #x; #y +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-regular-definitions-static-computed-names.js b/test/language/expressions/class/fields-regular-definitions-static-computed-names.js index 561a7b7f505a4ceb3f5423333fefdd8cea0f8284..8879a1750c94c1d56afdc381b60311cd9886b44b 100644 --- a/test/language/expressions/class/fields-regular-definitions-static-computed-names.js +++ b/test/language/expressions/class/fields-regular-definitions-static-computed-names.js @@ -24,6 +24,7 @@ info: | var C = class { static ["a"] = 42; ["a"] = 39 + } var c = new C(); diff --git a/test/language/expressions/class/fields-regular-definitions-static-computed-symbol-names.js b/test/language/expressions/class/fields-regular-definitions-static-computed-symbol-names.js index 8b4cc347f3237d71d6b2d37c5bb3cac822af5fa7..29eb4ddfac9e0251a4c80620359188ce31585cec 100644 --- a/test/language/expressions/class/fields-regular-definitions-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-regular-definitions-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42 + } var c = new C(); diff --git a/test/language/expressions/class/fields-regular-definitions-static-literal-names.js b/test/language/expressions/class/fields-regular-definitions-static-literal-names.js index c7219210e136066bb691c442d102e7e0a04a6061..fc69466a9f10e7682b9abc64db0f09503205990b 100644 --- a/test/language/expressions/class/fields-regular-definitions-static-literal-names.js +++ b/test/language/expressions/class/fields-regular-definitions-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { static a; b = 42; static c = fn + } var c = new C(); diff --git a/test/language/expressions/class/fields-regular-definitions-static-private-names.js b/test/language/expressions/class/fields-regular-definitions-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..7d2f657dd021ff4e8040c6b2b18cedcf140bd48e --- /dev/null +++ b/test/language/expressions/class/fields-regular-definitions-static-private-names.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-regular-definitions.template +/*--- +description: literal private names (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static #x; static #y +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-regular-definitions-string-literal-names.js b/test/language/expressions/class/fields-regular-definitions-string-literal-names.js index 6636aa21abe6988342102f06d2ebfee72bc9b72e..e3c88c0dfd721494cf889950fd6a24b83526b5c5 100644 --- a/test/language/expressions/class/fields-regular-definitions-string-literal-names.js +++ b/test/language/expressions/class/fields-regular-definitions-string-literal-names.js @@ -24,6 +24,7 @@ info: | var C = class { 'a'; "b"; 'c' = 39; "d" = 42 + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-gen-computed-names.js b/test/language/expressions/class/fields-same-line-async-gen-computed-names.js index 0755918d0f2aba3b73f151d40fbcd30d83644483..f408cfc76ee17b3d9673e6bd0698304cf7de4403 100644 --- a/test/language/expressions/class/fields-same-line-async-gen-computed-names.js +++ b/test/language/expressions/class/fields-same-line-async-gen-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; var C = class { async *m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-gen-computed-symbol-names.js b/test/language/expressions/class/fields-same-line-async-gen-computed-symbol-names.js index a02b46b4e5538450529c7dc0811f88bfa944b17b..ef71fb51ed3749519e529ca560ad2880bad8c8b0 100644 --- a/test/language/expressions/class/fields-same-line-async-gen-computed-symbol-names.js +++ b/test/language/expressions/class/fields-same-line-async-gen-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { async *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-gen-literal-names.js b/test/language/expressions/class/fields-same-line-async-gen-literal-names.js index c3dc382d5c69a7946ba604de7f6e7d24e281ddb3..2d319f7076a024cea7f1ea17e6db5362242445ce 100644 --- a/test/language/expressions/class/fields-same-line-async-gen-literal-names.js +++ b/test/language/expressions/class/fields-same-line-async-gen-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { async *m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-gen-private-names.js b/test/language/expressions/class/fields-same-line-async-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..91f10dea0821f4a7a6a76f7fdeddedd67868eaca --- /dev/null +++ b/test/language/expressions/class/fields-same-line-async-gen-private-names.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-after-same-line-async-gen.template +/*--- +description: static literal private names (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-iteration] +flags: [generated, async] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + async *m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/expressions/class/fields-same-line-async-gen-static-computed-names.js b/test/language/expressions/class/fields-same-line-async-gen-static-computed-names.js index 0f0fe55d58c057b9da55e6a368fe5d620864ae83..cdcef449d93a763801969457734cc690df158087 100644 --- a/test/language/expressions/class/fields-same-line-async-gen-static-computed-names.js +++ b/test/language/expressions/class/fields-same-line-async-gen-static-computed-names.js @@ -24,6 +24,7 @@ info: | var C = class { async *m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-gen-static-computed-symbol-names.js b/test/language/expressions/class/fields-same-line-async-gen-static-computed-symbol-names.js index 6b88f56e46c963ba11cfc48be04cf2d20f12c587..05a1577c21f0536e4a5bd7c73de1f59f996a5e8f 100644 --- a/test/language/expressions/class/fields-same-line-async-gen-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-same-line-async-gen-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { async *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-gen-static-literal-names.js b/test/language/expressions/class/fields-same-line-async-gen-static-literal-names.js index 84ebcbff9c56a0a6f07b00de08a2ec9925191e71..62152bfb5eb664f374520f4e76ae8982ce5408d7 100644 --- a/test/language/expressions/class/fields-same-line-async-gen-static-literal-names.js +++ b/test/language/expressions/class/fields-same-line-async-gen-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { async *m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-gen-static-private-names.js b/test/language/expressions/class/fields-same-line-async-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..f4103058a0d9cce4f60db575cc4c8b3a0b3bdf71 --- /dev/null +++ b/test/language/expressions/class/fields-same-line-async-gen-static-private-names.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-after-same-line-async-gen.template +/*--- +description: literal private names (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-iteration] +flags: [generated, async] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + async *m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/expressions/class/fields-same-line-async-gen-string-literal-names.js b/test/language/expressions/class/fields-same-line-async-gen-string-literal-names.js index 6201b2ee9f3de81972a7bd0d0f4196ddcaf311eb..e234e6a251f04798b4d40efa5d85b808763b639a 100644 --- a/test/language/expressions/class/fields-same-line-async-gen-string-literal-names.js +++ b/test/language/expressions/class/fields-same-line-async-gen-string-literal-names.js @@ -24,6 +24,7 @@ info: | var C = class { async *m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-method-computed-names.js b/test/language/expressions/class/fields-same-line-async-method-computed-names.js index 1cfdda572034090fa286e4141c46f6c47995f96d..f0c94430fcfb1d8f83843cd740cc030e3c61f653 100644 --- a/test/language/expressions/class/fields-same-line-async-method-computed-names.js +++ b/test/language/expressions/class/fields-same-line-async-method-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; var C = class { async m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-method-computed-symbol-names.js b/test/language/expressions/class/fields-same-line-async-method-computed-symbol-names.js index c350934b08a625cc3bfa847bc959312623088f93..cd350573ef7a0ed566ff51e739aa1af39596f973 100644 --- a/test/language/expressions/class/fields-same-line-async-method-computed-symbol-names.js +++ b/test/language/expressions/class/fields-same-line-async-method-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { async m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-method-literal-names.js b/test/language/expressions/class/fields-same-line-async-method-literal-names.js index efe14403cf9a024292aa91a7c61d72021bdcadb9..43fe91047fda11ec101975c02ed764cc639b5b8f 100644 --- a/test/language/expressions/class/fields-same-line-async-method-literal-names.js +++ b/test/language/expressions/class/fields-same-line-async-method-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { async m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-method-private-names.js b/test/language/expressions/class/fields-same-line-async-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..2953e2086d9b8255584dc15801b7b396eb24ce70 --- /dev/null +++ b/test/language/expressions/class/fields-same-line-async-method-private-names.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-after-same-line-async-method.template +/*--- +description: static literal private names (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-functions] +flags: [generated, async] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + async m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); + +c.m().then(function(v) { + assert.sameValue(v, 42); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/expressions/class/fields-same-line-async-method-static-computed-names.js b/test/language/expressions/class/fields-same-line-async-method-static-computed-names.js index 481ba48e0fc3aa99a14c7381ff97f5826994f431..dfbf3851f60b38146371b39ab1f41973694f7d55 100644 --- a/test/language/expressions/class/fields-same-line-async-method-static-computed-names.js +++ b/test/language/expressions/class/fields-same-line-async-method-static-computed-names.js @@ -24,6 +24,7 @@ info: | var C = class { async m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-method-static-computed-symbol-names.js b/test/language/expressions/class/fields-same-line-async-method-static-computed-symbol-names.js index 7d8db59d263bef3e387d2eef84b7c566b135873e..6582fc2633df6b84b9cb2250859e85d1a7836ab7 100644 --- a/test/language/expressions/class/fields-same-line-async-method-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-same-line-async-method-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { async m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-method-static-literal-names.js b/test/language/expressions/class/fields-same-line-async-method-static-literal-names.js index da30532722a002ad27d9de21a1bec34c620185dc..7939ee10170ad8d5bb8dedd7732b092c5c76f8bb 100644 --- a/test/language/expressions/class/fields-same-line-async-method-static-literal-names.js +++ b/test/language/expressions/class/fields-same-line-async-method-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { async m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-async-method-static-private-names.js b/test/language/expressions/class/fields-same-line-async-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..e9eaff6fefe774fff7e3c254897d1ae3b09f0652 --- /dev/null +++ b/test/language/expressions/class/fields-same-line-async-method-static-private-names.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-after-same-line-async-method.template +/*--- +description: literal private names (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-functions] +flags: [generated, async] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + async m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); + +c.m().then(function(v) { + assert.sameValue(v, 42); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/expressions/class/fields-same-line-async-method-string-literal-names.js b/test/language/expressions/class/fields-same-line-async-method-string-literal-names.js index 30ed0aac6b825c90ef61a926cf548e380c8a2078..af5eddbfb5699247e426d703e400bbc885765fdd 100644 --- a/test/language/expressions/class/fields-same-line-async-method-string-literal-names.js +++ b/test/language/expressions/class/fields-same-line-async-method-string-literal-names.js @@ -24,6 +24,7 @@ info: | var C = class { async m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-gen-computed-names.js b/test/language/expressions/class/fields-same-line-gen-computed-names.js index 2b0fba7c56cacf536b4dc8b8b82a362e69e01a31..c67abb310440a74a3ef3a7c658e7d333aed01df0 100644 --- a/test/language/expressions/class/fields-same-line-gen-computed-names.js +++ b/test/language/expressions/class/fields-same-line-gen-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; var C = class { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-gen-computed-symbol-names.js b/test/language/expressions/class/fields-same-line-gen-computed-symbol-names.js index f6ea225438eb20a2e9bf9de3ee9b1d70a8dc52c6..e9384c0be54681da956b76bb289b039f1b4441a9 100644 --- a/test/language/expressions/class/fields-same-line-gen-computed-symbol-names.js +++ b/test/language/expressions/class/fields-same-line-gen-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-gen-literal-names.js b/test/language/expressions/class/fields-same-line-gen-literal-names.js index 39da637603aead50f784b5fa0fed116567924296..df9d20e47b962e09e5e943da433393eeaae286bc 100644 --- a/test/language/expressions/class/fields-same-line-gen-literal-names.js +++ b/test/language/expressions/class/fields-same-line-gen-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { a; b = 42; c = fn; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-gen-private-names.js b/test/language/expressions/class/fields-same-line-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..db78242bcd84d10abd818c8f2fd762ef5c2f6de2 --- /dev/null +++ b/test/language/expressions/class/fields-same-line-gen-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-same-line-generator.template +/*--- +description: static literal private names (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields, generators] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + #x; #y; *m() { return 42; } +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-same-line-gen-static-computed-names.js b/test/language/expressions/class/fields-same-line-gen-static-computed-names.js index cb38eb406c4298cf98a868b06d65e9234abeabdd..9b0cc9600e73d341736c0dbf5d1d3e09dee842db 100644 --- a/test/language/expressions/class/fields-same-line-gen-static-computed-names.js +++ b/test/language/expressions/class/fields-same-line-gen-static-computed-names.js @@ -24,6 +24,7 @@ info: | var C = class { static ["a"] = 42; ["a"] = 39; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-gen-static-computed-symbol-names.js b/test/language/expressions/class/fields-same-line-gen-static-computed-symbol-names.js index 46ca7a8c174d768942782033b32d73a04a1c9f39..a01a5ede38421b409d934fc37eada4aee9058928 100644 --- a/test/language/expressions/class/fields-same-line-gen-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-same-line-gen-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-gen-static-literal-names.js b/test/language/expressions/class/fields-same-line-gen-static-literal-names.js index dc13ee4b803d95861147b4433c52140d0b104f53..91736e57794912d53db7a424652fa6e964c9e291 100644 --- a/test/language/expressions/class/fields-same-line-gen-static-literal-names.js +++ b/test/language/expressions/class/fields-same-line-gen-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { static a; b = 42; static c = fn; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-gen-static-private-names.js b/test/language/expressions/class/fields-same-line-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..21db44d20c7b3744e673ecdb72fda20fe525c8a3 --- /dev/null +++ b/test/language/expressions/class/fields-same-line-gen-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-same-line-generator.template +/*--- +description: literal private names (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields, generators] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static #x; static #y; *m() { return 42; } +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-same-line-gen-string-literal-names.js b/test/language/expressions/class/fields-same-line-gen-string-literal-names.js index 8f6e5c4b71bf369a1082688a38f60dfd5263e83c..aecc8d8300446427c5225625c0331b6e74f878e1 100644 --- a/test/language/expressions/class/fields-same-line-gen-string-literal-names.js +++ b/test/language/expressions/class/fields-same-line-gen-string-literal-names.js @@ -24,6 +24,7 @@ info: | var C = class { 'a'; "b"; 'c' = 39; "d" = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-method-computed-names.js b/test/language/expressions/class/fields-same-line-method-computed-names.js index 8faaddf426fe4ec8e474a39ac5884c744dd33305..198e9c76654749d132b0d43e80793865e6b2a487 100644 --- a/test/language/expressions/class/fields-same-line-method-computed-names.js +++ b/test/language/expressions/class/fields-same-line-method-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; var C = class { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-method-computed-symbol-names.js b/test/language/expressions/class/fields-same-line-method-computed-symbol-names.js index 3a3bd34f80ffbc7f262f6d58b833ebf624d4a283..546335b13136319882506e2e00aa9cb2df0a6f6c 100644 --- a/test/language/expressions/class/fields-same-line-method-computed-symbol-names.js +++ b/test/language/expressions/class/fields-same-line-method-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-method-literal-names.js b/test/language/expressions/class/fields-same-line-method-literal-names.js index ee772500264cc1e7b675670a218a0540f6dac150..cb60f45d6d850b60b5cca23474682c12fe4197b6 100644 --- a/test/language/expressions/class/fields-same-line-method-literal-names.js +++ b/test/language/expressions/class/fields-same-line-method-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { a; b = 42; c = fn; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-method-private-names.js b/test/language/expressions/class/fields-same-line-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..7bbab8a370f69d5749a411c0247402e25704b898 --- /dev/null +++ b/test/language/expressions/class/fields-same-line-method-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-same-line-method.template +/*--- +description: static literal private names (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + #x; #y; m() { return 42; } +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-same-line-method-static-computed-names.js b/test/language/expressions/class/fields-same-line-method-static-computed-names.js index 8e3cd8f51f76702aac7c5a5e31eecbb60f407312..5930c06f30c3a4661ff292fc6da144a782c44ffe 100644 --- a/test/language/expressions/class/fields-same-line-method-static-computed-names.js +++ b/test/language/expressions/class/fields-same-line-method-static-computed-names.js @@ -24,6 +24,7 @@ info: | var C = class { static ["a"] = 42; ["a"] = 39; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-method-static-computed-symbol-names.js b/test/language/expressions/class/fields-same-line-method-static-computed-symbol-names.js index 09083ff8af6a92be00f8a7db68aadc3b536fb2bf..dd393a37da6eb6583575da1cf7d6d83fd8f99b68 100644 --- a/test/language/expressions/class/fields-same-line-method-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-same-line-method-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); var C = class { [x]; [y] = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-method-static-literal-names.js b/test/language/expressions/class/fields-same-line-method-static-literal-names.js index 0f579bca909e57647b8cb6559dc0ca853258fbde..2777dc90ca7cefd48b5a9828cb70cf63e7c33a7e 100644 --- a/test/language/expressions/class/fields-same-line-method-static-literal-names.js +++ b/test/language/expressions/class/fields-same-line-method-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} var C = class { static a; b = 42; static c = fn; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-same-line-method-static-private-names.js b/test/language/expressions/class/fields-same-line-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..64fd72a2ef17d7db90494c0cba9ea318128d366b --- /dev/null +++ b/test/language/expressions/class/fields-same-line-method-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-same-line-method.template +/*--- +description: literal private names (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + static #x; static #y; m() { return 42; } +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-same-line-method-string-literal-names.js b/test/language/expressions/class/fields-same-line-method-string-literal-names.js index 3f39a6c02174fde296e57b632e3330b015b1ce5d..1f55af229bf9018e040d65a05a190ce02a71a9b5 100644 --- a/test/language/expressions/class/fields-same-line-method-string-literal-names.js +++ b/test/language/expressions/class/fields-same-line-method-string-literal-names.js @@ -24,6 +24,7 @@ info: | var C = class { 'a'; "b"; 'c' = 39; "d" = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/expressions/class/fields-wrapped-in-sc-computed-names.js b/test/language/expressions/class/fields-wrapped-in-sc-computed-names.js index 51fdf456a69e5c5bfa62fafedeb3c6b370d27655..2178a39831b034a9aaaa786fac062cb558dc7b82 100644 --- a/test/language/expressions/class/fields-wrapped-in-sc-computed-names.js +++ b/test/language/expressions/class/fields-wrapped-in-sc-computed-names.js @@ -27,6 +27,7 @@ var C = class { ;;;; ;;;;;;static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"];;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/expressions/class/fields-wrapped-in-sc-computed-symbol-names.js b/test/language/expressions/class/fields-wrapped-in-sc-computed-symbol-names.js index b67852992689023c76c4e00ad1d3ebf4ea3b7a1d..7745a0ebe3a36c83c2278cdfdb43fcb4fbf7a52d 100644 --- a/test/language/expressions/class/fields-wrapped-in-sc-computed-symbol-names.js +++ b/test/language/expressions/class/fields-wrapped-in-sc-computed-symbol-names.js @@ -28,6 +28,7 @@ var C = class { ;;;; ;;;;;;[x]; [y] = 42;;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/expressions/class/fields-wrapped-in-sc-literal-names.js b/test/language/expressions/class/fields-wrapped-in-sc-literal-names.js index 7a5080a738e23ef56ecdfce1f9b1e7965ac9250f..9b6701e6d4e398db67cf57b83de402252f7d271c 100644 --- a/test/language/expressions/class/fields-wrapped-in-sc-literal-names.js +++ b/test/language/expressions/class/fields-wrapped-in-sc-literal-names.js @@ -28,6 +28,7 @@ var C = class { ;;;;;;a; b = 42; c = fn;;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/expressions/class/fields-wrapped-in-sc-private-names.js b/test/language/expressions/class/fields-wrapped-in-sc-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..7ddf759a57c5f0fa52058de0c74cd9c567c4b4e6 --- /dev/null +++ b/test/language/expressions/class/fields-wrapped-in-sc-private-names.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-expr-wrapped-in-sc.template +/*--- +description: static literal private names (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + ;;;; + ;;;;;;#x; #y;;;;;;; + ;;;; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-wrapped-in-sc-static-computed-names.js b/test/language/expressions/class/fields-wrapped-in-sc-static-computed-names.js index 34025f9b2e0aa0f77ea8fd0d2c0ed9e0e284fe50..5a15b36a27bf709ecbaa3de0d2ce469b33df1e7d 100644 --- a/test/language/expressions/class/fields-wrapped-in-sc-static-computed-names.js +++ b/test/language/expressions/class/fields-wrapped-in-sc-static-computed-names.js @@ -26,6 +26,7 @@ var C = class { ;;;; ;;;;;;static ["a"] = 42; ["a"] = 39;;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/expressions/class/fields-wrapped-in-sc-static-computed-symbol-names.js b/test/language/expressions/class/fields-wrapped-in-sc-static-computed-symbol-names.js index b8fb78a25aabeb760a8781f9a3b755725bb63bb2..77aec775d427a745dc1c1fd20abc64f1816d75f7 100644 --- a/test/language/expressions/class/fields-wrapped-in-sc-static-computed-symbol-names.js +++ b/test/language/expressions/class/fields-wrapped-in-sc-static-computed-symbol-names.js @@ -28,6 +28,7 @@ var C = class { ;;;; ;;;;;;[x]; [y] = 42;;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/expressions/class/fields-wrapped-in-sc-static-literal-names.js b/test/language/expressions/class/fields-wrapped-in-sc-static-literal-names.js index 89167a37469b22fab4822f36e221654d154f38ad..f9f5bee3cb1d17c697ec57295560fac208b08644 100644 --- a/test/language/expressions/class/fields-wrapped-in-sc-static-literal-names.js +++ b/test/language/expressions/class/fields-wrapped-in-sc-static-literal-names.js @@ -28,6 +28,7 @@ var C = class { ;;;;;;static a; b = 42; static c = fn;;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/expressions/class/fields-wrapped-in-sc-static-private-names.js b/test/language/expressions/class/fields-wrapped-in-sc-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..e057d939894adc37a5fc091a1aae361c017e2187 --- /dev/null +++ b/test/language/expressions/class/fields-wrapped-in-sc-static-private-names.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-expr-wrapped-in-sc.template +/*--- +description: literal private names (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +var C = class { + ;;;; + ;;;;;;static #x; static #y;;;;;;; + ;;;; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/expressions/class/fields-wrapped-in-sc-string-literal-names.js b/test/language/expressions/class/fields-wrapped-in-sc-string-literal-names.js index da2af62bb45b3e9934904e419791b54c6b62f91c..b053d3f2c075573ec89e8e612a49ad3232536338 100644 --- a/test/language/expressions/class/fields-wrapped-in-sc-string-literal-names.js +++ b/test/language/expressions/class/fields-wrapped-in-sc-string-literal-names.js @@ -26,6 +26,7 @@ var C = class { ;;;;;;'a'; "b"; 'c' = 39; "d" = 42;;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-gen-computed-names.js b/test/language/statements/class/fields-after-same-line-gen-computed-names.js index c065aa9ce29879e421f1caa8d6610ca6b28b8f81..2e69fe1de41992d230330ed7dc6e42e05c36d5b7 100644 --- a/test/language/statements/class/fields-after-same-line-gen-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-gen-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; class C { *m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-gen-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-gen-computed-symbol-names.js index b660d1516fc4b47ea2d3f1f52b4b7d2b16297cc3..532c5fb81a96fa0a675654b3ab13cea8c6b7c83b 100644 --- a/test/language/statements/class/fields-after-same-line-gen-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-gen-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-gen-literal-names.js b/test/language/statements/class/fields-after-same-line-gen-literal-names.js index aefe0864e2584e2a8d0e9ae5219761ab5a24d240..64b5878a42dd2f6fd504aabc16d20514547c2596 100644 --- a/test/language/statements/class/fields-after-same-line-gen-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-gen-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { *m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-gen-private-names.js b/test/language/statements/class/fields-after-same-line-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..4dc789e3ba2c0a72b05b2572064cc2b477903d89 --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-gen-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-after-same-line-gen.template +/*--- +description: static literal private names (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [generators, class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + *m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-after-same-line-gen-static-computed-names.js b/test/language/statements/class/fields-after-same-line-gen-static-computed-names.js index 28592739c2be9dc2114926102ab65ef3be5ba4f3..1714b3e19f08d55c96f40c1a04beb89310343b1b 100644 --- a/test/language/statements/class/fields-after-same-line-gen-static-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-gen-static-computed-names.js @@ -24,6 +24,7 @@ info: | class C { *m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-gen-static-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-gen-static-computed-symbol-names.js index 1f77fc4342962106a27288685902e26005b0c79b..8e737374a324d40965d98e2d5e72b567a2fd6719 100644 --- a/test/language/statements/class/fields-after-same-line-gen-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-gen-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-gen-static-literal-names.js b/test/language/statements/class/fields-after-same-line-gen-static-literal-names.js index d88e1347546ad1e94ffb45712567542e85d05929..3eb013c219ecd24f433ec550f51c5fcb50cb3e72 100644 --- a/test/language/statements/class/fields-after-same-line-gen-static-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-gen-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { *m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-gen-static-private-names.js b/test/language/statements/class/fields-after-same-line-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..72a274976d491319e8c2ba84e6650244372c5d92 --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-gen-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-after-same-line-gen.template +/*--- +description: literal private names (field definitions after a generator in the same line) +esid: prod-FieldDefinition +features: [generators, class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + *m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-after-same-line-gen-string-literal-names.js b/test/language/statements/class/fields-after-same-line-gen-string-literal-names.js index a3fe6c62de30a6878abaec7a3227d83f4d8bfcef..f03c5b26258b23d35b50398e5ade04e137c6dd2b 100644 --- a/test/language/statements/class/fields-after-same-line-gen-string-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-gen-string-literal-names.js @@ -24,6 +24,7 @@ info: | class C { *m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-method-computed-names.js b/test/language/statements/class/fields-after-same-line-method-computed-names.js index 6933e4b941eeb37a67360e566da4f262e55dd6b6..b8cce540f36f111a5ed6144b0404840dfea6f609 100644 --- a/test/language/statements/class/fields-after-same-line-method-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-method-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; class C { m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-method-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-method-computed-symbol-names.js index 129f49c98dec62e2d43cba2223199435e0b6d2de..2c228a4c1f7b73b912fa66c34a82a3558933ef3c 100644 --- a/test/language/statements/class/fields-after-same-line-method-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-method-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-method-literal-names.js b/test/language/statements/class/fields-after-same-line-method-literal-names.js index a0facfffdb15fc4b3feeb17fa1544db00a12cbe4..5217248204e12f06c31b53c117d3341098514236 100644 --- a/test/language/statements/class/fields-after-same-line-method-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-method-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-method-private-names.js b/test/language/statements/class/fields-after-same-line-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..f399c371c38e1222d10d0215bd5aa807acbb8c88 --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-method-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-after-same-line-method.template +/*--- +description: static literal private names (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-after-same-line-method-static-computed-names.js b/test/language/statements/class/fields-after-same-line-method-static-computed-names.js index 7c454d2ba9cf7133e506de7fd7ae35acd8832773..131e855153b5c8da05c683bd79a18ecd0ba9252a 100644 --- a/test/language/statements/class/fields-after-same-line-method-static-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-method-static-computed-names.js @@ -24,6 +24,7 @@ info: | class C { m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-method-static-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-method-static-computed-symbol-names.js index d529c257ed58d4cb9ef385d6a7761140dada04c6..0abf67a8f987955426d912e5844de6f78931dc36 100644 --- a/test/language/statements/class/fields-after-same-line-method-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-method-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-method-static-literal-names.js b/test/language/statements/class/fields-after-same-line-method-static-literal-names.js index 5f63b572fdc51020c02af63e3896be39d68dc141..1d175ffa47495805b6b21c88f012aed98ef6ecf2 100644 --- a/test/language/statements/class/fields-after-same-line-method-static-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-method-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-method-static-private-names.js b/test/language/statements/class/fields-after-same-line-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..0c18445e06e160c9c35663cf6b38d3d86d0ce606 --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-method-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-after-same-line-method.template +/*--- +description: literal private names (field definitions after a method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-after-same-line-method-string-literal-names.js b/test/language/statements/class/fields-after-same-line-method-string-literal-names.js index c6222fa49fd4a9a27800f931c1573b0226ee8abd..ec1ead9be5fd442197eea95b748a71763a3c23a7 100644 --- a/test/language/statements/class/fields-after-same-line-method-string-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-method-string-literal-names.js @@ -24,6 +24,7 @@ info: | class C { m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-gen-computed-names.js b/test/language/statements/class/fields-after-same-line-static-async-gen-computed-names.js index 41e3e931041a88b9e1f4912696facffa5057cffd..5662b1106f83f0e60073883a5dcc2a5ee203c5ff 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-gen-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-gen-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; class C { static async *m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-gen-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-static-async-gen-computed-symbol-names.js index 468e2b35d5a7607702a457f05ea04da19a36d7dc..43a25adcb910dc388051b79bd7c80168c9935a80 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-gen-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-gen-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { static async *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-gen-literal-names.js b/test/language/statements/class/fields-after-same-line-static-async-gen-literal-names.js index 5ce9a6054d4ca8f15d28817f46cd6f57fb392510..06142a248c006aea01636cdb5979823389908972 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-gen-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-gen-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { static async *m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-gen-private-names.js b/test/language/statements/class/fields-after-same-line-static-async-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..19c10607e8734862c91a16de5a533f1ea8dc267e --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-static-async-gen-private-names.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-after-same-line-static-async-gen.template +/*--- +description: static literal private names (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-iteration] +flags: [generated, async] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static async *m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/statements/class/fields-after-same-line-static-async-gen-static-computed-names.js b/test/language/statements/class/fields-after-same-line-static-async-gen-static-computed-names.js index 09427e35e2dd7c692820f981101bf950a723217a..966e0817b00544aa16c004a25cd387f9d8d6b53c 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-gen-static-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-gen-static-computed-names.js @@ -24,6 +24,7 @@ info: | class C { static async *m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-gen-static-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-static-async-gen-static-computed-symbol-names.js index 7b90798bb327cb76a7f70b699b2def7d95d08c28..bd93cf5b5744b8bda31424d4897394bfd2ec812f 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-gen-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-gen-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { static async *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-gen-static-literal-names.js b/test/language/statements/class/fields-after-same-line-static-async-gen-static-literal-names.js index e72e69a3f3dac9731c98f2a6aae826a6d8ac6c86..8aeaec51ac28b4b4a1495669702c279b44cc4fc4 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-gen-static-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-gen-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { static async *m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-gen-static-private-names.js b/test/language/statements/class/fields-after-same-line-static-async-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..02fef686920337c2789bb10d51cb55deaaddaa6f --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-static-async-gen-static-private-names.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-after-same-line-static-async-gen.template +/*--- +description: literal private names (field definitions after a static async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-iteration] +flags: [generated, async] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static async *m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); + +C.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/statements/class/fields-after-same-line-static-async-gen-string-literal-names.js b/test/language/statements/class/fields-after-same-line-static-async-gen-string-literal-names.js index 7b698a4528d1488f138b2e520e25f7571103b8f2..e20ea1e2767b8d1748970b52391fc0177f8bacff 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-gen-string-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-gen-string-literal-names.js @@ -24,6 +24,7 @@ info: | class C { static async *m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-method-computed-names.js b/test/language/statements/class/fields-after-same-line-static-async-method-computed-names.js index 44fa754faa425ce116f63919ec04232535140bab..18cd384ed08053c00f5969941419903632df8488 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-method-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-method-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; class C { static async m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-method-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-static-async-method-computed-symbol-names.js index ebc558f7ee6e4457542132b22d608fd29ed6e636..ba746b259affb7f8998db3e15d456fc9e42f49f0 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-method-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-method-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { static async m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-method-literal-names.js b/test/language/statements/class/fields-after-same-line-static-async-method-literal-names.js index daa3eb6f3935f643f80ba06aeabfb17123d56e8a..f6491d50e068728ee8d541fc146ff29139ffb311 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-method-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-method-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { static async m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-method-private-names.js b/test/language/statements/class/fields-after-same-line-static-async-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..bfe3cb9923c917d15fcc730e7be186329ab570b3 --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-static-async-method-private-names.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-after-same-line-static-async-method.template +/*--- +description: static literal private names (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-functions] +flags: [generated, async] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static async m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); + +C.m().then(function(v) { + assert.sameValue(v, 42); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/statements/class/fields-after-same-line-static-async-method-static-computed-names.js b/test/language/statements/class/fields-after-same-line-static-async-method-static-computed-names.js index 074733ef001dcecb6ae675a0537c5fc199f1aff0..1903ccd1932fe22b71e4c52b7dbb987d7da7c3ee 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-method-static-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-method-static-computed-names.js @@ -24,6 +24,7 @@ info: | class C { static async m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-method-static-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-static-async-method-static-computed-symbol-names.js index dccfeccbca31c32c3f8e6407b1861ee07189f7f7..82b80339c0b86c7048c4d3e8b0eacfad78c82ecf 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-method-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-method-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { static async m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-method-static-literal-names.js b/test/language/statements/class/fields-after-same-line-static-async-method-static-literal-names.js index 797d3f344996d079c2ff4ffe4394c59da1f77bae..9ee0a2d901880eebea973ecbbc87d1f190394a8e 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-method-static-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-method-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { static async m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-async-method-static-private-names.js b/test/language/statements/class/fields-after-same-line-static-async-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..9b59318c79d2bd75575e13da6833c63d226c292f --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-static-async-method-static-private-names.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-after-same-line-static-async-method.template +/*--- +description: literal private names (field definitions after a static async method in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-functions] +flags: [generated, async] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static async m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); + +C.m().then(function(v) { + assert.sameValue(v, 42); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/statements/class/fields-after-same-line-static-async-method-string-literal-names.js b/test/language/statements/class/fields-after-same-line-static-async-method-string-literal-names.js index e78203eb908dd005c5bbe546eb495a9d879a7258..25d5739783412ff43e75c9706cca8d45ae390c69 100644 --- a/test/language/statements/class/fields-after-same-line-static-async-method-string-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-async-method-string-literal-names.js @@ -24,6 +24,7 @@ info: | class C { static async m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-gen-computed-names.js b/test/language/statements/class/fields-after-same-line-static-gen-computed-names.js index 5cccb361c59d6e7652130d49513d38ed76f3e430..3d3630e5b0700b04dfea757a1669ab38b1119004 100644 --- a/test/language/statements/class/fields-after-same-line-static-gen-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-static-gen-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; class C { static *m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-gen-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-static-gen-computed-symbol-names.js index 10a206d172650a2928d8baeca4811fc5ebf13280..c4a3ab1b52a1f2054322f975e1fb1aa536f6bacc 100644 --- a/test/language/statements/class/fields-after-same-line-static-gen-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-static-gen-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { static *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-gen-literal-names.js b/test/language/statements/class/fields-after-same-line-static-gen-literal-names.js index 7fda7a16ade14328242e1c44f1a5236ceca517e0..6cf085ffe333948594c6c6e55431ce7fe36e2a51 100644 --- a/test/language/statements/class/fields-after-same-line-static-gen-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-gen-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { static *m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-gen-private-names.js b/test/language/statements/class/fields-after-same-line-static-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..8a2a3af3c228eaf7a80abc36845814b82762277c --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-static-gen-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-after-same-line-static-gen.template +/*--- +description: static literal private names (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [generators, class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static *m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-after-same-line-static-gen-static-computed-names.js b/test/language/statements/class/fields-after-same-line-static-gen-static-computed-names.js index f82bd491db1496839632bb3b13e26a100ccaac70..6f5684977125b9f60d946d18db6ea989ac642ce0 100644 --- a/test/language/statements/class/fields-after-same-line-static-gen-static-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-static-gen-static-computed-names.js @@ -24,6 +24,7 @@ info: | class C { static *m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-gen-static-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-static-gen-static-computed-symbol-names.js index 6a16e2c9f9c6edacffdb6e6633e48c4e50819abc..7c145d15f0892c972bbfd671c9f1ead9b0641bd8 100644 --- a/test/language/statements/class/fields-after-same-line-static-gen-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-static-gen-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { static *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-gen-static-literal-names.js b/test/language/statements/class/fields-after-same-line-static-gen-static-literal-names.js index 27c082886ec6dafea377d9877bae42a71bafc1af..b0941f34260a238f26145732c1c2b07084f36e42 100644 --- a/test/language/statements/class/fields-after-same-line-static-gen-static-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-gen-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { static *m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-gen-static-private-names.js b/test/language/statements/class/fields-after-same-line-static-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..c8feba6c931bf29a619cbfe57c08fa78844487d8 --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-static-gen-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-after-same-line-static-gen.template +/*--- +description: literal private names (field definitions after a static generator in the same line) +esid: prod-FieldDefinition +features: [generators, class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static *m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m().next().value, 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-after-same-line-static-gen-string-literal-names.js b/test/language/statements/class/fields-after-same-line-static-gen-string-literal-names.js index 88ecc889852d9f8206fcd3352f1cbaa60aa62e14..ea9fbf7c29421ed263c133e66ad5dbab309e3eb8 100644 --- a/test/language/statements/class/fields-after-same-line-static-gen-string-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-gen-string-literal-names.js @@ -24,6 +24,7 @@ info: | class C { static *m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-method-computed-names.js b/test/language/statements/class/fields-after-same-line-static-method-computed-names.js index 53b8e3bb5dbd3ddbdfcc9d1781bb9e00e79fb4e3..fc7b80248f05666187874df9071633801c7291e5 100644 --- a/test/language/statements/class/fields-after-same-line-static-method-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-static-method-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; class C { static m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-method-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-static-method-computed-symbol-names.js index bab33bb16561f57866e0604578f24c288a0c09f5..f20707ab32b0ee40bc2b3673239de84dc330ba9b 100644 --- a/test/language/statements/class/fields-after-same-line-static-method-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-static-method-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { static m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-method-literal-names.js b/test/language/statements/class/fields-after-same-line-static-method-literal-names.js index 8cf005134e4e29d6003df6195c05a020dee0929f..32dffcf65ee424ca0e77f681497a19b0d1751b92 100644 --- a/test/language/statements/class/fields-after-same-line-static-method-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-method-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { static m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-method-private-names.js b/test/language/statements/class/fields-after-same-line-static-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..45f5e7ae741701f92fdb3869bc5ae00dbb8c6169 --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-static-method-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-after-same-line-static-method.template +/*--- +description: static literal private names (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-after-same-line-static-method-static-computed-names.js b/test/language/statements/class/fields-after-same-line-static-method-static-computed-names.js index 4b196c0a4122d8d603660cf504bbdacc8eadc17b..09196da792ea16d1794a89b13183a863d6fd8372 100644 --- a/test/language/statements/class/fields-after-same-line-static-method-static-computed-names.js +++ b/test/language/statements/class/fields-after-same-line-static-method-static-computed-names.js @@ -24,6 +24,7 @@ info: | class C { static m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-method-static-computed-symbol-names.js b/test/language/statements/class/fields-after-same-line-static-method-static-computed-symbol-names.js index 153d0320b398d4e3abc4195da76636545a765768..4f1f908b91f4816337e0bffc9d2bd9a006fb8aba 100644 --- a/test/language/statements/class/fields-after-same-line-static-method-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-after-same-line-static-method-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { static m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-method-static-literal-names.js b/test/language/statements/class/fields-after-same-line-static-method-static-literal-names.js index 43341468bd14d4f3617a05bfc2b181d5b28d3b44..92978d97c5930bc4a87f0f2e7643342d8fab005c 100644 --- a/test/language/statements/class/fields-after-same-line-static-method-static-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-method-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { static m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-after-same-line-static-method-static-private-names.js b/test/language/statements/class/fields-after-same-line-static-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..5062d1a9ba7b698144d6c4a09decb5cc1f8a1625 --- /dev/null +++ b/test/language/statements/class/fields-after-same-line-static-method-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-after-same-line-static-method.template +/*--- +description: literal private names (field definitions after a static method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(C.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "m"), false); + +verifyProperty(C, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-after-same-line-static-method-string-literal-names.js b/test/language/statements/class/fields-after-same-line-static-method-string-literal-names.js index 0e4a59e6aff087518a2e4d73481e742d3dc7100a..7d9ff3f5cf3a95bf2d5341702199f9e891fe0e07 100644 --- a/test/language/statements/class/fields-after-same-line-static-method-string-literal-names.js +++ b/test/language/statements/class/fields-after-same-line-static-method-string-literal-names.js @@ -24,6 +24,7 @@ info: | class C { static m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-definitions-computed-names.js b/test/language/statements/class/fields-multiple-definitions-computed-names.js index 8c15af84f4bec48eb43b66b37163265f483839b2..4294f2c25eb93ccbeb4555eba9759036c5c3bef6 100644 --- a/test/language/statements/class/fields-multiple-definitions-computed-names.js +++ b/test/language/statements/class/fields-multiple-definitions-computed-names.js @@ -29,6 +29,7 @@ class C { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"] m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-definitions-computed-symbol-names.js b/test/language/statements/class/fields-multiple-definitions-computed-symbol-names.js index 28f0a8845b9f42cd18ae8810af9be42dcc5c7881..b7be8668b971088219e0494ce069d5e273444974 100644 --- a/test/language/statements/class/fields-multiple-definitions-computed-symbol-names.js +++ b/test/language/statements/class/fields-multiple-definitions-computed-symbol-names.js @@ -30,6 +30,7 @@ class C { [x]; [y] = 42 m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-definitions-literal-names.js b/test/language/statements/class/fields-multiple-definitions-literal-names.js index de483bfa225246dd5058455923a6d9c071d90e1d..9dc40ee6e06fd8b5f6041e10133b9043eaa96f1a 100644 --- a/test/language/statements/class/fields-multiple-definitions-literal-names.js +++ b/test/language/statements/class/fields-multiple-definitions-literal-names.js @@ -30,6 +30,7 @@ class C { c = fn m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-definitions-private-names.js b/test/language/statements/class/fields-multiple-definitions-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..b33dd705461525fe1c8182d8c0a0a28ae3ccaca6 --- /dev/null +++ b/test/language/statements/class/fields-multiple-definitions-private-names.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-multiple-definitions.template +/*--- +description: static literal private names (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + #x; #y + m2() { return 39 } + bar = "barbaz"; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert.sameValue(Object.hasOwnProperty.call(c, "m2"), false); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert.sameValue(Object.hasOwnProperty.call(C, "foo"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "foo"), false); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert.sameValue(Object.hasOwnProperty.call(C, "bar"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "bar"), false); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-multiple-definitions-static-computed-names.js b/test/language/statements/class/fields-multiple-definitions-static-computed-names.js index 09293f69f0b2e6985aff0c0aad941eea6fd87ea6..944e702051390e30a197ae1bfde186402e143cb6 100644 --- a/test/language/statements/class/fields-multiple-definitions-static-computed-names.js +++ b/test/language/statements/class/fields-multiple-definitions-static-computed-names.js @@ -28,6 +28,7 @@ class C { static ["a"] = 42; ["a"] = 39 m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-definitions-static-computed-symbol-names.js b/test/language/statements/class/fields-multiple-definitions-static-computed-symbol-names.js index b0d336fdfd8092a4e7a9d73b89740214a9aee74b..c3b178ad600d83b7317cb5ca18b835f7c4ec26c6 100644 --- a/test/language/statements/class/fields-multiple-definitions-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-multiple-definitions-static-computed-symbol-names.js @@ -30,6 +30,7 @@ class C { [x]; [y] = 42 m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-definitions-static-literal-names.js b/test/language/statements/class/fields-multiple-definitions-static-literal-names.js index 672f36cd14fa44cbbac06b6857d0ad8e69b12525..8d3da71b393bb8387b68cae128402dc277d23ef9 100644 --- a/test/language/statements/class/fields-multiple-definitions-static-literal-names.js +++ b/test/language/statements/class/fields-multiple-definitions-static-literal-names.js @@ -30,6 +30,7 @@ class C { static c = fn m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-definitions-static-private-names.js b/test/language/statements/class/fields-multiple-definitions-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..fe883fde242b0df44639dd2ca2e2ddd79b0d2495 --- /dev/null +++ b/test/language/statements/class/fields-multiple-definitions-static-private-names.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-multiple-definitions.template +/*--- +description: literal private names (multiple fields definitions) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + foo = "foobar"; + m() { return 42 } + static #x; static #y + m2() { return 39 } + bar = "barbaz"; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.m2(), 39); +assert.sameValue(Object.hasOwnProperty.call(c, "m2"), false); +assert.sameValue(c.m2, C.prototype.m2); + +verifyProperty(C.prototype, "m2", { + enumerable: false, + configurable: true, + writable: true, +}); + +assert.sameValue(c.foo, "foobar"); +assert.sameValue(Object.hasOwnProperty.call(C, "foo"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "foo"), false); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert.sameValue(Object.hasOwnProperty.call(C, "bar"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "bar"), false); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-multiple-definitions-string-literal-names.js b/test/language/statements/class/fields-multiple-definitions-string-literal-names.js index 0bdc1974815bce605725addcbc491b8b45c510f5..c8942f783bfe2e2e4785594824953c276bad1dec 100644 --- a/test/language/statements/class/fields-multiple-definitions-string-literal-names.js +++ b/test/language/statements/class/fields-multiple-definitions-string-literal-names.js @@ -28,6 +28,7 @@ class C { "d" = 42 m2() { return 39 } bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-stacked-definitions-computed-names.js b/test/language/statements/class/fields-multiple-stacked-definitions-computed-names.js index e84d859b83b1e3abc178d9b8d79d87d1fa77ec6c..bc6141881d14373d59a0c5cabe2ccbaa29fd173e 100644 --- a/test/language/statements/class/fields-multiple-stacked-definitions-computed-names.js +++ b/test/language/statements/class/fields-multiple-stacked-definitions-computed-names.js @@ -27,6 +27,7 @@ class C { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"] foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-stacked-definitions-computed-symbol-names.js b/test/language/statements/class/fields-multiple-stacked-definitions-computed-symbol-names.js index a829009a15e49635acf712bfa889168a3767501f..d25cd008688322f403fe103302639534747ef3e3 100644 --- a/test/language/statements/class/fields-multiple-stacked-definitions-computed-symbol-names.js +++ b/test/language/statements/class/fields-multiple-stacked-definitions-computed-symbol-names.js @@ -28,6 +28,7 @@ class C { [x]; [y] = 42 foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-stacked-definitions-literal-names.js b/test/language/statements/class/fields-multiple-stacked-definitions-literal-names.js index 8992888f6ae79989b9562f181ec713c81ce0e319..e2c3689cb91473fe34ad13a1c11b4d0c13d33dc3 100644 --- a/test/language/statements/class/fields-multiple-stacked-definitions-literal-names.js +++ b/test/language/statements/class/fields-multiple-stacked-definitions-literal-names.js @@ -28,6 +28,7 @@ class C { c = fn foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-stacked-definitions-private-names.js b/test/language/statements/class/fields-multiple-stacked-definitions-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..e9b855f9eb2e463580afd7838d44804a7ba2eb4a --- /dev/null +++ b/test/language/statements/class/fields-multiple-stacked-definitions-private-names.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-multiple-stacked-definitions.template +/*--- +description: static literal private names (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + #x; #y + foo = "foobar" + bar = "barbaz"; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert.sameValue(Object.hasOwnProperty.call(C, "foo"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "foo"), false); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert.sameValue(Object.hasOwnProperty.call(C, "bar"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "bar"), false); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-multiple-stacked-definitions-static-computed-names.js b/test/language/statements/class/fields-multiple-stacked-definitions-static-computed-names.js index 7cf2fe27179006ed8b201b3b67ba795267fecadb..b87ec755f9d4020d476b6ad05bb5530ea3ca028d 100644 --- a/test/language/statements/class/fields-multiple-stacked-definitions-static-computed-names.js +++ b/test/language/statements/class/fields-multiple-stacked-definitions-static-computed-names.js @@ -26,6 +26,7 @@ class C { static ["a"] = 42; ["a"] = 39 foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-stacked-definitions-static-computed-symbol-names.js b/test/language/statements/class/fields-multiple-stacked-definitions-static-computed-symbol-names.js index d41baa279fffb6cbf16ad1b7714ee47028752ba8..4d82de70d5d5083a96d9cce5a143ce279b832e7e 100644 --- a/test/language/statements/class/fields-multiple-stacked-definitions-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-multiple-stacked-definitions-static-computed-symbol-names.js @@ -28,6 +28,7 @@ class C { [x]; [y] = 42 foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-stacked-definitions-static-literal-names.js b/test/language/statements/class/fields-multiple-stacked-definitions-static-literal-names.js index 906c3f943b5f29fad2640aed9f4cbd24bfb1c270..a9b1304004ea5fe7821417def02716f318032ffd 100644 --- a/test/language/statements/class/fields-multiple-stacked-definitions-static-literal-names.js +++ b/test/language/statements/class/fields-multiple-stacked-definitions-static-literal-names.js @@ -28,6 +28,7 @@ class C { static c = fn foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-multiple-stacked-definitions-static-private-names.js b/test/language/statements/class/fields-multiple-stacked-definitions-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..b0bcd84f79a767482b79ddaeb36cf5a394dd43c2 --- /dev/null +++ b/test/language/statements/class/fields-multiple-stacked-definitions-static-private-names.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-multiple-stacked-definitions.template +/*--- +description: literal private names (multiple stacked fields definitions through ASI) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static #x; static #y + foo = "foobar" + bar = "barbaz"; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.foo, "foobar"); +assert.sameValue(Object.hasOwnProperty.call(C, "foo"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "foo"), false); + +verifyProperty(c, "foo", { + value: "foobar", + enumerable: true, + configurable: true, + writable: true, +}); + +assert.sameValue(c.bar, "barbaz"); +assert.sameValue(Object.hasOwnProperty.call(C, "bar"), false); +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "bar"), false); + +verifyProperty(c, "bar", { + value: "barbaz", + enumerable: true, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-multiple-stacked-definitions-string-literal-names.js b/test/language/statements/class/fields-multiple-stacked-definitions-string-literal-names.js index fb7754104716e815e4b2170576a514c4ee6f6081..84d3f59529e256e20877c08eb502ad174cbd8d3d 100644 --- a/test/language/statements/class/fields-multiple-stacked-definitions-string-literal-names.js +++ b/test/language/statements/class/fields-multiple-stacked-definitions-string-literal-names.js @@ -26,6 +26,7 @@ class C { "d" = 42 foo = "foobar" bar = "barbaz"; + } var c = new C(); diff --git a/test/language/statements/class/fields-new-no-sc-line-method-computed-names.js b/test/language/statements/class/fields-new-no-sc-line-method-computed-names.js index 013601d8804ad76e0e2e4f503a89065079aee73f..239282f2b3bed99e7cf1581f74ee07dbbdf24f5a 100644 --- a/test/language/statements/class/fields-new-no-sc-line-method-computed-names.js +++ b/test/language/statements/class/fields-new-no-sc-line-method-computed-names.js @@ -26,6 +26,7 @@ var x = "b"; class C { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"] m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-no-sc-line-method-computed-symbol-names.js b/test/language/statements/class/fields-new-no-sc-line-method-computed-symbol-names.js index b35333bea16c7614bfa5e04645f0860e5b1aa9d0..9b9590ba8edceb2d6a1112ac203c2368336e06b1 100644 --- a/test/language/statements/class/fields-new-no-sc-line-method-computed-symbol-names.js +++ b/test/language/statements/class/fields-new-no-sc-line-method-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); class C { [x]; [y] = 42 m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-no-sc-line-method-literal-names.js b/test/language/statements/class/fields-new-no-sc-line-method-literal-names.js index 0f81ff3861be2caaf9b8232143d33a0210c4832c..e5cdf9402b4ee332983face500fa767ff1830333 100644 --- a/test/language/statements/class/fields-new-no-sc-line-method-literal-names.js +++ b/test/language/statements/class/fields-new-no-sc-line-method-literal-names.js @@ -27,6 +27,7 @@ class C { a; b = 42; c = fn m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-no-sc-line-method-private-names.js b/test/language/statements/class/fields-new-no-sc-line-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..faea882b9e9ce4dfaeb507b77f279ed58b4dc7c8 --- /dev/null +++ b/test/language/statements/class/fields-new-no-sc-line-method-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-new-no-sc-line-method.template +/*--- +description: static literal private names (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + #x; #y + m() { return 42; } +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-new-no-sc-line-method-static-computed-names.js b/test/language/statements/class/fields-new-no-sc-line-method-static-computed-names.js index d6e4ea3793619669aea81515bba14003fef8dc7e..79f6a88fefb84a9f749a70550c3ce3fc2c62504d 100644 --- a/test/language/statements/class/fields-new-no-sc-line-method-static-computed-names.js +++ b/test/language/statements/class/fields-new-no-sc-line-method-static-computed-names.js @@ -25,6 +25,7 @@ info: | class C { static ["a"] = 42; ["a"] = 39 m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-no-sc-line-method-static-computed-symbol-names.js b/test/language/statements/class/fields-new-no-sc-line-method-static-computed-symbol-names.js index ef9cd465e7fd7454cf379772c2a4ce4e0afb70b9..a90c7a44553c90aaba91b93f5180b7e5d3d0c091 100644 --- a/test/language/statements/class/fields-new-no-sc-line-method-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-new-no-sc-line-method-static-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); class C { [x]; [y] = 42 m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-no-sc-line-method-static-literal-names.js b/test/language/statements/class/fields-new-no-sc-line-method-static-literal-names.js index 8bd683b9c1be260d1f0ae9d454bade99406e736e..98f7c9aa882afdc885d796701acb7d55bc68b8b5 100644 --- a/test/language/statements/class/fields-new-no-sc-line-method-static-literal-names.js +++ b/test/language/statements/class/fields-new-no-sc-line-method-static-literal-names.js @@ -27,6 +27,7 @@ class C { static a; b = 42; static c = fn m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-no-sc-line-method-static-private-names.js b/test/language/statements/class/fields-new-no-sc-line-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..4317c7914ad9d66ad052f5f64d24d18252576556 --- /dev/null +++ b/test/language/statements/class/fields-new-no-sc-line-method-static-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-new-no-sc-line-method.template +/*--- +description: literal private names (field definitions followed by a method in a new line without a semicolon) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static #x; static #y + m() { return 42; } +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-new-no-sc-line-method-string-literal-names.js b/test/language/statements/class/fields-new-no-sc-line-method-string-literal-names.js index f653063e9e32dfcb507471978aeaab0d69362d7f..99d49b49cb0234633c9bbcfad09270525644d1d3 100644 --- a/test/language/statements/class/fields-new-no-sc-line-method-string-literal-names.js +++ b/test/language/statements/class/fields-new-no-sc-line-method-string-literal-names.js @@ -25,6 +25,7 @@ class C { 'a'; "b"; 'c' = 39; "d" = 42 m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-gen-computed-names.js b/test/language/statements/class/fields-new-sc-line-gen-computed-names.js index 25d735e9f6301e437a3056e5eacf595611334374..493a327787d135c4cf0842457b152f766ec994cf 100644 --- a/test/language/statements/class/fields-new-sc-line-gen-computed-names.js +++ b/test/language/statements/class/fields-new-sc-line-gen-computed-names.js @@ -26,6 +26,7 @@ var x = "b"; class C { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-gen-computed-symbol-names.js b/test/language/statements/class/fields-new-sc-line-gen-computed-symbol-names.js index 771e1f1761e658c6048321f7de49823f12e147cd..83ec80c1d2668b4580e1d0938b5afb47be2cc903 100644 --- a/test/language/statements/class/fields-new-sc-line-gen-computed-symbol-names.js +++ b/test/language/statements/class/fields-new-sc-line-gen-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); class C { [x]; [y] = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-gen-literal-names.js b/test/language/statements/class/fields-new-sc-line-gen-literal-names.js index 9a645cb45dc677a4dcec1a47b159f87db08e1c5d..724fdf9bfe9c3cf53b763311774f8e135d361705 100644 --- a/test/language/statements/class/fields-new-sc-line-gen-literal-names.js +++ b/test/language/statements/class/fields-new-sc-line-gen-literal-names.js @@ -27,6 +27,7 @@ class C { a; b = 42; c = fn; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-gen-private-names.js b/test/language/statements/class/fields-new-sc-line-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..dd4e4e4edb28dea19b76d0a8485cc1fba680dd0a --- /dev/null +++ b/test/language/statements/class/fields-new-sc-line-gen-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-new-sc-line-generator.template +/*--- +description: static literal private names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields, generators] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + #x; #y; + *m() { return 42; } +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-new-sc-line-gen-static-computed-names.js b/test/language/statements/class/fields-new-sc-line-gen-static-computed-names.js index fd4c046dfec914f4727feb7c6ccd801e422fabbc..28d063451e977cd2ea252e7e6764bdbf141a1944 100644 --- a/test/language/statements/class/fields-new-sc-line-gen-static-computed-names.js +++ b/test/language/statements/class/fields-new-sc-line-gen-static-computed-names.js @@ -25,6 +25,7 @@ info: | class C { static ["a"] = 42; ["a"] = 39; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-gen-static-computed-symbol-names.js b/test/language/statements/class/fields-new-sc-line-gen-static-computed-symbol-names.js index d965b31d0a3a3da7277af3ef9a0cd70b0ac22c64..e4bf73ea61a9054c2a897479f2a59aa13b33d066 100644 --- a/test/language/statements/class/fields-new-sc-line-gen-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-new-sc-line-gen-static-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); class C { [x]; [y] = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-gen-static-literal-names.js b/test/language/statements/class/fields-new-sc-line-gen-static-literal-names.js index 58b5cbb20c57b2dce15c170cadb6a0e827585fd0..d29d2e04e02acdfb927e23e9d12973366e20dee9 100644 --- a/test/language/statements/class/fields-new-sc-line-gen-static-literal-names.js +++ b/test/language/statements/class/fields-new-sc-line-gen-static-literal-names.js @@ -27,6 +27,7 @@ class C { static a; b = 42; static c = fn; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-gen-static-private-names.js b/test/language/statements/class/fields-new-sc-line-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..f624f26259407e5fbb1e36cd67231eea99ac9293 --- /dev/null +++ b/test/language/statements/class/fields-new-sc-line-gen-static-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-new-sc-line-generator.template +/*--- +description: literal private names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields, generators] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static #x; static #y; + *m() { return 42; } +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-new-sc-line-gen-string-literal-names.js b/test/language/statements/class/fields-new-sc-line-gen-string-literal-names.js index 79a7607ab6b45922ab50618167bae2afeed09751..8e6ba68c54f140c59ef9b863ca4558af58541a67 100644 --- a/test/language/statements/class/fields-new-sc-line-gen-string-literal-names.js +++ b/test/language/statements/class/fields-new-sc-line-gen-string-literal-names.js @@ -25,6 +25,7 @@ class C { 'a'; "b"; 'c' = 39; "d" = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-method-computed-names.js b/test/language/statements/class/fields-new-sc-line-method-computed-names.js index d7403fd73545ae0ed1bee0f30e2932f57cf72d7b..f7fe3f3365b2705a825d9a351d922f8851e175e0 100644 --- a/test/language/statements/class/fields-new-sc-line-method-computed-names.js +++ b/test/language/statements/class/fields-new-sc-line-method-computed-names.js @@ -26,6 +26,7 @@ var x = "b"; class C { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-method-computed-symbol-names.js b/test/language/statements/class/fields-new-sc-line-method-computed-symbol-names.js index bb1a24b3148e0d2645b97b73eaea238b7320b7f6..51d944e0bd4ac84324dbbf9c600b6c9f6c7a6ad6 100644 --- a/test/language/statements/class/fields-new-sc-line-method-computed-symbol-names.js +++ b/test/language/statements/class/fields-new-sc-line-method-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); class C { [x]; [y] = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-method-literal-names.js b/test/language/statements/class/fields-new-sc-line-method-literal-names.js index 7d23f42bb3fd799ece0f33e6a0036a0e6649fb1c..1b48da7ba09f5f7281bc86b3f199819955d8dd72 100644 --- a/test/language/statements/class/fields-new-sc-line-method-literal-names.js +++ b/test/language/statements/class/fields-new-sc-line-method-literal-names.js @@ -27,6 +27,7 @@ class C { a; b = 42; c = fn; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-method-private-names.js b/test/language/statements/class/fields-new-sc-line-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..cdc9649b62f9ac443787a460448312ef5e7456bf --- /dev/null +++ b/test/language/statements/class/fields-new-sc-line-method-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-new-sc-line-method.template +/*--- +description: static literal private names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + #x; #y; + m() { return 42; } +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-new-sc-line-method-static-computed-names.js b/test/language/statements/class/fields-new-sc-line-method-static-computed-names.js index 26c6d4e1943462e5a307c54c20ec494b7d9df2f9..4dc70efe936c6551487aa07a24f649262e52478d 100644 --- a/test/language/statements/class/fields-new-sc-line-method-static-computed-names.js +++ b/test/language/statements/class/fields-new-sc-line-method-static-computed-names.js @@ -25,6 +25,7 @@ info: | class C { static ["a"] = 42; ["a"] = 39; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-method-static-computed-symbol-names.js b/test/language/statements/class/fields-new-sc-line-method-static-computed-symbol-names.js index 91b260883f50e00d4e13f32408d072874cdafbe6..9bcf7aaa0fd9024e9851225301cc3519c02e4db3 100644 --- a/test/language/statements/class/fields-new-sc-line-method-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-new-sc-line-method-static-computed-symbol-names.js @@ -27,6 +27,7 @@ var y = Symbol(); class C { [x]; [y] = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-method-static-literal-names.js b/test/language/statements/class/fields-new-sc-line-method-static-literal-names.js index f86f7da7abc7b8fa0c6f6ecfa4010c05f3886722..577d066624f194c0cc6aebbe98535a3a2395846d 100644 --- a/test/language/statements/class/fields-new-sc-line-method-static-literal-names.js +++ b/test/language/statements/class/fields-new-sc-line-method-static-literal-names.js @@ -27,6 +27,7 @@ class C { static a; b = 42; static c = fn; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-new-sc-line-method-static-private-names.js b/test/language/statements/class/fields-new-sc-line-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..89cf71314bbd3149d741c0bfa778c8b8cd06caf4 --- /dev/null +++ b/test/language/statements/class/fields-new-sc-line-method-static-private-names.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-new-sc-line-method.template +/*--- +description: literal private names (field definitions followed by a method in a new line with a semicolon) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static #x; static #y; + m() { return 42; } +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-new-sc-line-method-string-literal-names.js b/test/language/statements/class/fields-new-sc-line-method-string-literal-names.js index 713991137eb046f7e7ae197ae25af1c7cb696e89..bcf19587a6dc0f388cd5fb3bb7c2d8c0922a10c0 100644 --- a/test/language/statements/class/fields-new-sc-line-method-string-literal-names.js +++ b/test/language/statements/class/fields-new-sc-line-method-string-literal-names.js @@ -25,6 +25,7 @@ class C { 'a'; "b"; 'c' = 39; "d" = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-regular-definitions-computed-names.js b/test/language/statements/class/fields-regular-definitions-computed-names.js index 331ef29084665e412cf6dc934c5992af116b263b..0e85698b3955ddadfa1e5a94545f88c46ec9d4da 100644 --- a/test/language/statements/class/fields-regular-definitions-computed-names.js +++ b/test/language/statements/class/fields-regular-definitions-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; class C { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"] + } var c = new C(); diff --git a/test/language/statements/class/fields-regular-definitions-computed-symbol-names.js b/test/language/statements/class/fields-regular-definitions-computed-symbol-names.js index 8ad7d540950f3e15234bddd485774ae4c9d7edb4..683a6ccef3f238fbc771e799820098aec6ac425d 100644 --- a/test/language/statements/class/fields-regular-definitions-computed-symbol-names.js +++ b/test/language/statements/class/fields-regular-definitions-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { [x]; [y] = 42 + } var c = new C(); diff --git a/test/language/statements/class/fields-regular-definitions-literal-names.js b/test/language/statements/class/fields-regular-definitions-literal-names.js index f4710fd7bda83f30693a974f7f4f68c7204c5c00..0782d14a99bf563e6dfb720d8423f80c83590fa0 100644 --- a/test/language/statements/class/fields-regular-definitions-literal-names.js +++ b/test/language/statements/class/fields-regular-definitions-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { a; b = 42; c = fn + } var c = new C(); diff --git a/test/language/statements/class/fields-regular-definitions-private-names.js b/test/language/statements/class/fields-regular-definitions-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..7e4651ab3ce463cddf107351451cfaacf4cd5c46 --- /dev/null +++ b/test/language/statements/class/fields-regular-definitions-private-names.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-regular-definitions.template +/*--- +description: static literal private names (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + #x; #y +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-regular-definitions-static-computed-names.js b/test/language/statements/class/fields-regular-definitions-static-computed-names.js index bad49f1af3a3f41850eb25443c4d41575da1f124..ae920aa497905fcaef25998fa90bca47cac08c9a 100644 --- a/test/language/statements/class/fields-regular-definitions-static-computed-names.js +++ b/test/language/statements/class/fields-regular-definitions-static-computed-names.js @@ -24,6 +24,7 @@ info: | class C { static ["a"] = 42; ["a"] = 39 + } var c = new C(); diff --git a/test/language/statements/class/fields-regular-definitions-static-computed-symbol-names.js b/test/language/statements/class/fields-regular-definitions-static-computed-symbol-names.js index a713299d5fd0d4c1931f59ee21c29d2a65b4b4fd..c385f741583ac49775d1ec112d99473b0806c459 100644 --- a/test/language/statements/class/fields-regular-definitions-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-regular-definitions-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { [x]; [y] = 42 + } var c = new C(); diff --git a/test/language/statements/class/fields-regular-definitions-static-literal-names.js b/test/language/statements/class/fields-regular-definitions-static-literal-names.js index d032244bb4031fd9d4d06effc0cd8b6c1b5124fb..0a5bd05aac25de0d68cb7a95535cc463cbeed428 100644 --- a/test/language/statements/class/fields-regular-definitions-static-literal-names.js +++ b/test/language/statements/class/fields-regular-definitions-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { static a; b = 42; static c = fn + } var c = new C(); diff --git a/test/language/statements/class/fields-regular-definitions-static-private-names.js b/test/language/statements/class/fields-regular-definitions-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..7ba1403474c76c05c40b92e619d4e9c3f53eb468 --- /dev/null +++ b/test/language/statements/class/fields-regular-definitions-static-private-names.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-regular-definitions.template +/*--- +description: literal private names (regular fields defintion) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static #x; static #y +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-regular-definitions-string-literal-names.js b/test/language/statements/class/fields-regular-definitions-string-literal-names.js index f56f41323b9950afc23f25a7fd2b9658d97db717..1a445b4a73b329d479d6be65b7e3a843b558b1b3 100644 --- a/test/language/statements/class/fields-regular-definitions-string-literal-names.js +++ b/test/language/statements/class/fields-regular-definitions-string-literal-names.js @@ -24,6 +24,7 @@ info: | class C { 'a'; "b"; 'c' = 39; "d" = 42 + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-gen-computed-names.js b/test/language/statements/class/fields-same-line-async-gen-computed-names.js index 0f7c38f1b3ba78ee609250ba829b018bdb7c88dc..ac8cacad708596c1df27305ef9026387e07eea32 100644 --- a/test/language/statements/class/fields-same-line-async-gen-computed-names.js +++ b/test/language/statements/class/fields-same-line-async-gen-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; class C { async *m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-gen-computed-symbol-names.js b/test/language/statements/class/fields-same-line-async-gen-computed-symbol-names.js index a228b840373b3cc0a723186040496fc945fab8a3..9852dfbc48d32f16aaafc519cb726c3ca45a94a3 100644 --- a/test/language/statements/class/fields-same-line-async-gen-computed-symbol-names.js +++ b/test/language/statements/class/fields-same-line-async-gen-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { async *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-gen-literal-names.js b/test/language/statements/class/fields-same-line-async-gen-literal-names.js index 166b2d15b05e96e98b49ab647317b846135ec492..ec2409554d94dda6ffc840138cd6decd485f065f 100644 --- a/test/language/statements/class/fields-same-line-async-gen-literal-names.js +++ b/test/language/statements/class/fields-same-line-async-gen-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { async *m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-gen-private-names.js b/test/language/statements/class/fields-same-line-async-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..81f89c94016122db914ea3b5ba97c1d7c3aadbf8 --- /dev/null +++ b/test/language/statements/class/fields-same-line-async-gen-private-names.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-after-same-line-async-gen.template +/*--- +description: static literal private names (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-iteration] +flags: [generated, async] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + async *m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/statements/class/fields-same-line-async-gen-static-computed-names.js b/test/language/statements/class/fields-same-line-async-gen-static-computed-names.js index f324abb96ff46ecee92cc38fb542debbb7364383..bfb56491720e480db29915cb7e338d29cbc6c316 100644 --- a/test/language/statements/class/fields-same-line-async-gen-static-computed-names.js +++ b/test/language/statements/class/fields-same-line-async-gen-static-computed-names.js @@ -24,6 +24,7 @@ info: | class C { async *m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-gen-static-computed-symbol-names.js b/test/language/statements/class/fields-same-line-async-gen-static-computed-symbol-names.js index f674c4e16343f5a01eb5ca97b020cffef3cd64f1..b4ef5d8038addc0fd60d4e3cfb8021fad2a4b46a 100644 --- a/test/language/statements/class/fields-same-line-async-gen-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-same-line-async-gen-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { async *m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-gen-static-literal-names.js b/test/language/statements/class/fields-same-line-async-gen-static-literal-names.js index 4bca5f27a4ec8059c2fd2b9a85f5881e0ef238d9..cffbe5f17a61fa3193bc277dd5dac62296cfc687 100644 --- a/test/language/statements/class/fields-same-line-async-gen-static-literal-names.js +++ b/test/language/statements/class/fields-same-line-async-gen-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { async *m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-gen-static-private-names.js b/test/language/statements/class/fields-same-line-async-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..a77dcc91c05db6c0b51c274421d2d74cbb2c9aae --- /dev/null +++ b/test/language/statements/class/fields-same-line-async-gen-static-private-names.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-after-same-line-async-gen.template +/*--- +description: literal private names (field definitions after an async generator in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-iteration] +flags: [generated, async] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + async *m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); + +c.m().next().then(function(v) { + assert.sameValue(v.value, 42); + assert.sameValue(v.done, true); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/statements/class/fields-same-line-async-gen-string-literal-names.js b/test/language/statements/class/fields-same-line-async-gen-string-literal-names.js index 7c01efaea37aa596933c0b3aba6a3fda49834dff..2c243305c49113f5a813341485323df668633b70 100644 --- a/test/language/statements/class/fields-same-line-async-gen-string-literal-names.js +++ b/test/language/statements/class/fields-same-line-async-gen-string-literal-names.js @@ -24,6 +24,7 @@ info: | class C { async *m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-method-computed-names.js b/test/language/statements/class/fields-same-line-async-method-computed-names.js index 68e037e0059b95d970f9bbb9f57fc5d5e7320eda..f0c5c733817b286297c4b4649d24b69efaa14787 100644 --- a/test/language/statements/class/fields-same-line-async-method-computed-names.js +++ b/test/language/statements/class/fields-same-line-async-method-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; class C { async m() { return 42; } static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-method-computed-symbol-names.js b/test/language/statements/class/fields-same-line-async-method-computed-symbol-names.js index 4f02dbe52d462790ed2f8bdcd92b503ca634e26a..efec870e33ee205da33f56ce80f9595743528755 100644 --- a/test/language/statements/class/fields-same-line-async-method-computed-symbol-names.js +++ b/test/language/statements/class/fields-same-line-async-method-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { async m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-method-literal-names.js b/test/language/statements/class/fields-same-line-async-method-literal-names.js index 67536a51a328cc66145e4840ce7d727dc6aaa17d..7c0ceceef34852e7af484e2078c7d5a79add391f 100644 --- a/test/language/statements/class/fields-same-line-async-method-literal-names.js +++ b/test/language/statements/class/fields-same-line-async-method-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { async m() { return 42; } a; b = 42; c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-method-private-names.js b/test/language/statements/class/fields-same-line-async-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..e21a55ef96ed002f111c1934448c2c0da64307b2 --- /dev/null +++ b/test/language/statements/class/fields-same-line-async-method-private-names.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-after-same-line-async-method.template +/*--- +description: static literal private names (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-functions] +flags: [generated, async] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + async m() { return 42; } #x; #y; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); + +c.m().then(function(v) { + assert.sameValue(v, 42); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/statements/class/fields-same-line-async-method-static-computed-names.js b/test/language/statements/class/fields-same-line-async-method-static-computed-names.js index 0b472e348cd85f28b7808b3d568db62bb8d22692..10e9395f7fe554d1ffca0ed61102e7e2005a7bb8 100644 --- a/test/language/statements/class/fields-same-line-async-method-static-computed-names.js +++ b/test/language/statements/class/fields-same-line-async-method-static-computed-names.js @@ -24,6 +24,7 @@ info: | class C { async m() { return 42; } static ["a"] = 42; ["a"] = 39; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-method-static-computed-symbol-names.js b/test/language/statements/class/fields-same-line-async-method-static-computed-symbol-names.js index 230544aa565d3d9da222246a7b17546769433328..972b4d1adadfffc52b096fb82f0fa38b4d5c68ee 100644 --- a/test/language/statements/class/fields-same-line-async-method-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-same-line-async-method-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { async m() { return 42; } [x]; [y] = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-method-static-literal-names.js b/test/language/statements/class/fields-same-line-async-method-static-literal-names.js index cecaa9bf0aa4b77239ed1bd578f40a30270bc81a..222b543ea322a146ed5a0f4173802584b6474686 100644 --- a/test/language/statements/class/fields-same-line-async-method-static-literal-names.js +++ b/test/language/statements/class/fields-same-line-async-method-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { async m() { return 42; } static a; b = 42; static c = fn; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-async-method-static-private-names.js b/test/language/statements/class/fields-same-line-async-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..1a979fe4f33e4b7d728d186bbb24059ec2240697 --- /dev/null +++ b/test/language/statements/class/fields-same-line-async-method-static-private-names.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-after-same-line-async-method.template +/*--- +description: literal private names (field definitions after an async method in the same line) +esid: prod-FieldDefinition +features: [class-fields, async-functions] +flags: [generated, async] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + async m() { return 42; } static #x; static #y; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); +assert.sameValue(c.m, C.prototype.m); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}, {restore: true}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); + +c.m().then(function(v) { + assert.sameValue(v, 42); +}, $DONE).then($DONE, $DONE); diff --git a/test/language/statements/class/fields-same-line-async-method-string-literal-names.js b/test/language/statements/class/fields-same-line-async-method-string-literal-names.js index c3415ec92557f51c2484b926c08faac998a3a864..41a045c9514e11dca77b23811e0ce378553a077c 100644 --- a/test/language/statements/class/fields-same-line-async-method-string-literal-names.js +++ b/test/language/statements/class/fields-same-line-async-method-string-literal-names.js @@ -24,6 +24,7 @@ info: | class C { async m() { return 42; } 'a'; "b"; 'c' = 39; "d" = 42; + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-gen-computed-names.js b/test/language/statements/class/fields-same-line-gen-computed-names.js index 7ce2a5a0c7e6c30f2eec0a6789572eb40493f7f9..1cd7bf8ac55d2daa83985da44ae5ecdc809ab812 100644 --- a/test/language/statements/class/fields-same-line-gen-computed-names.js +++ b/test/language/statements/class/fields-same-line-gen-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; class C { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-gen-computed-symbol-names.js b/test/language/statements/class/fields-same-line-gen-computed-symbol-names.js index ac8092d5bf733b76e68ccbd35d564e16b9a41ac4..976730d9ec5bd2a4a97b8f9facf3030b921659da 100644 --- a/test/language/statements/class/fields-same-line-gen-computed-symbol-names.js +++ b/test/language/statements/class/fields-same-line-gen-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { [x]; [y] = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-gen-literal-names.js b/test/language/statements/class/fields-same-line-gen-literal-names.js index 689e9cb2565d4f079241d9f6c10e29048c849722..38ee4803e4a70180c49d2dd9a3919b463de3cf55 100644 --- a/test/language/statements/class/fields-same-line-gen-literal-names.js +++ b/test/language/statements/class/fields-same-line-gen-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { a; b = 42; c = fn; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-gen-private-names.js b/test/language/statements/class/fields-same-line-gen-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..c9932a5d274fc7919cc8af1128e8d8ed59537c88 --- /dev/null +++ b/test/language/statements/class/fields-same-line-gen-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-same-line-generator.template +/*--- +description: static literal private names (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields, generators] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + #x; #y; *m() { return 42; } +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-same-line-gen-static-computed-names.js b/test/language/statements/class/fields-same-line-gen-static-computed-names.js index 6544e21aee72867f3f836e114a8984c35e83208e..4d5bb30a57497c47caad893a2e2282eb5db8cb7c 100644 --- a/test/language/statements/class/fields-same-line-gen-static-computed-names.js +++ b/test/language/statements/class/fields-same-line-gen-static-computed-names.js @@ -24,6 +24,7 @@ info: | class C { static ["a"] = 42; ["a"] = 39; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-gen-static-computed-symbol-names.js b/test/language/statements/class/fields-same-line-gen-static-computed-symbol-names.js index ec324d83562ca7bb35ca630a60a736feba0c3cd0..49c4af92ecdec133a0a2b33faf3ef17858adda87 100644 --- a/test/language/statements/class/fields-same-line-gen-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-same-line-gen-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { [x]; [y] = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-gen-static-literal-names.js b/test/language/statements/class/fields-same-line-gen-static-literal-names.js index 0a624e21c2d63f93b072f102645c419776d11100..13c4a747786f09e730c54f6860c9b5f7cc716950 100644 --- a/test/language/statements/class/fields-same-line-gen-static-literal-names.js +++ b/test/language/statements/class/fields-same-line-gen-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { static a; b = 42; static c = fn; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-gen-static-private-names.js b/test/language/statements/class/fields-same-line-gen-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..efd7f51e4a26c41ff9852344e710ffdf1fe236a1 --- /dev/null +++ b/test/language/statements/class/fields-same-line-gen-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-same-line-generator.template +/*--- +description: literal private names (field definitions followed by a generator method in the same line) +esid: prod-FieldDefinition +features: [class-fields, generators] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static #x; static #y; *m() { return 42; } +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m().next().value, 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-same-line-gen-string-literal-names.js b/test/language/statements/class/fields-same-line-gen-string-literal-names.js index 5eb4b491207d58d701d139502e0fc8419310f27a..b5fedce6275a472c319b9ed83275b4ee4ce51659 100644 --- a/test/language/statements/class/fields-same-line-gen-string-literal-names.js +++ b/test/language/statements/class/fields-same-line-gen-string-literal-names.js @@ -24,6 +24,7 @@ info: | class C { 'a'; "b"; 'c' = 39; "d" = 42; *m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-method-computed-names.js b/test/language/statements/class/fields-same-line-method-computed-names.js index a94d95379aee28b46f13907b9278054b65a8b37f..19b7c975c8641eb8ed79d3e430da02fbe82afa3d 100644 --- a/test/language/statements/class/fields-same-line-method-computed-names.js +++ b/test/language/statements/class/fields-same-line-method-computed-names.js @@ -25,6 +25,7 @@ var x = "b"; class C { static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"]; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-method-computed-symbol-names.js b/test/language/statements/class/fields-same-line-method-computed-symbol-names.js index e8ca9aa7793682562e1c408d900f39cb49a93c26..97a65e7392defed6c22d19cc194a3d0a2cebbe9c 100644 --- a/test/language/statements/class/fields-same-line-method-computed-symbol-names.js +++ b/test/language/statements/class/fields-same-line-method-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { [x]; [y] = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-method-literal-names.js b/test/language/statements/class/fields-same-line-method-literal-names.js index 35f339943ee099a2e6d5b199930487d98401d8b6..1a21e559ba99eb01493e3936d216bfd7a11195fb 100644 --- a/test/language/statements/class/fields-same-line-method-literal-names.js +++ b/test/language/statements/class/fields-same-line-method-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { a; b = 42; c = fn; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-method-private-names.js b/test/language/statements/class/fields-same-line-method-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..5103c757c8eb6c1f966b831d1035766648dabe90 --- /dev/null +++ b/test/language/statements/class/fields-same-line-method-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-same-line-method.template +/*--- +description: static literal private names (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + #x; #y; m() { return 42; } +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-same-line-method-static-computed-names.js b/test/language/statements/class/fields-same-line-method-static-computed-names.js index 7e0cf4ba85fdd577fb9ab11309bc1b99b3fddc4f..cf05838969984d5588cef3e659fa0156c8b18be3 100644 --- a/test/language/statements/class/fields-same-line-method-static-computed-names.js +++ b/test/language/statements/class/fields-same-line-method-static-computed-names.js @@ -24,6 +24,7 @@ info: | class C { static ["a"] = 42; ["a"] = 39; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-method-static-computed-symbol-names.js b/test/language/statements/class/fields-same-line-method-static-computed-symbol-names.js index 1f8cb7ae896c3dc0c0386eef527defbbee3ac287..5178507b42d6106247a2d60a40fdf1e2a3674c42 100644 --- a/test/language/statements/class/fields-same-line-method-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-same-line-method-static-computed-symbol-names.js @@ -26,6 +26,7 @@ var y = Symbol(); class C { [x]; [y] = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-method-static-literal-names.js b/test/language/statements/class/fields-same-line-method-static-literal-names.js index adee793e19c1ceedd332294e595e6b06a32d2e45..c31274b0220a72e4721ac9be848f2faf767dd106 100644 --- a/test/language/statements/class/fields-same-line-method-static-literal-names.js +++ b/test/language/statements/class/fields-same-line-method-static-literal-names.js @@ -26,6 +26,7 @@ const fn = function() {} class C { static a; b = 42; static c = fn; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-same-line-method-static-private-names.js b/test/language/statements/class/fields-same-line-method-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..0e46dc5e769f6eb742a46fe2a9f11fafc884ecdb --- /dev/null +++ b/test/language/statements/class/fields-same-line-method-static-private-names.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-same-line-method.template +/*--- +description: literal private names (field definitions followed by a method in the same line) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + static #x; static #y; m() { return 42; } +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +assert.sameValue(c.m(), 42); +assert.sameValue(c.m, C.prototype.m); +assert.sameValue(Object.hasOwnProperty.call(c, "m"), false); + +verifyProperty(C.prototype, "m", { + enumerable: false, + configurable: true, + writable: true, +}); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-same-line-method-string-literal-names.js b/test/language/statements/class/fields-same-line-method-string-literal-names.js index 1c7b66528ea04dee1aac44818e8e4b54d4634025..a80773cc03b8bb37ae0fe94137a72f152c54c0dc 100644 --- a/test/language/statements/class/fields-same-line-method-string-literal-names.js +++ b/test/language/statements/class/fields-same-line-method-string-literal-names.js @@ -24,6 +24,7 @@ info: | class C { 'a'; "b"; 'c' = 39; "d" = 42; m() { return 42; } + } var c = new C(); diff --git a/test/language/statements/class/fields-wrapped-in-sc-computed-names.js b/test/language/statements/class/fields-wrapped-in-sc-computed-names.js index a4729fb8ab848febf1a5fcea6d96a59915aa5ea4..c550ee442e56f49dc787e9fae3a2fd631983747f 100644 --- a/test/language/statements/class/fields-wrapped-in-sc-computed-names.js +++ b/test/language/statements/class/fields-wrapped-in-sc-computed-names.js @@ -27,6 +27,7 @@ class C { ;;;; ;;;;;;static ["a"] = 39; [x] = 42; [10] = "meep"; ["not initialized"];;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/statements/class/fields-wrapped-in-sc-computed-symbol-names.js b/test/language/statements/class/fields-wrapped-in-sc-computed-symbol-names.js index fc793e10cb28adb07b7fad99c872cac3f640f9a7..b1479ba3933f8f7d198a5130a37b3dad3f6ad2d2 100644 --- a/test/language/statements/class/fields-wrapped-in-sc-computed-symbol-names.js +++ b/test/language/statements/class/fields-wrapped-in-sc-computed-symbol-names.js @@ -28,6 +28,7 @@ class C { ;;;; ;;;;;;[x]; [y] = 42;;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/statements/class/fields-wrapped-in-sc-literal-names.js b/test/language/statements/class/fields-wrapped-in-sc-literal-names.js index 103b0e06e75fcde44d46ae3ba9aae2a13f98e636..44a9e1dbebd3c778940efe6f9512483c2b0db53b 100644 --- a/test/language/statements/class/fields-wrapped-in-sc-literal-names.js +++ b/test/language/statements/class/fields-wrapped-in-sc-literal-names.js @@ -28,6 +28,7 @@ class C { ;;;;;;a; b = 42; c = fn;;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/statements/class/fields-wrapped-in-sc-private-names.js b/test/language/statements/class/fields-wrapped-in-sc-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..9ee392647647af8a0196b5a909728fbf613fa0ac --- /dev/null +++ b/test/language/statements/class/fields-wrapped-in-sc-private-names.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/private-names.case +// - src/class-fields/default/cls-decl-wrapped-in-sc.template +/*--- +description: static literal private names (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + ;;;; + ;;;;;;#x; #y;;;;;;; + ;;;; +x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(c.x(), 42, "test 7"); +assert.sameValue(c.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-wrapped-in-sc-static-computed-names.js b/test/language/statements/class/fields-wrapped-in-sc-static-computed-names.js index 96434be4c2316c409020ca16d0fb6da2e1a0ea20..4a315dec74bfb51ecafe813649edf4a7c2629e3a 100644 --- a/test/language/statements/class/fields-wrapped-in-sc-static-computed-names.js +++ b/test/language/statements/class/fields-wrapped-in-sc-static-computed-names.js @@ -26,6 +26,7 @@ class C { ;;;; ;;;;;;static ["a"] = 42; ["a"] = 39;;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/statements/class/fields-wrapped-in-sc-static-computed-symbol-names.js b/test/language/statements/class/fields-wrapped-in-sc-static-computed-symbol-names.js index 3539cf1626ce6015b27e58870960198bc9f3ed09..e86fb600ccb5747bed40006e63d34ac274af2c36 100644 --- a/test/language/statements/class/fields-wrapped-in-sc-static-computed-symbol-names.js +++ b/test/language/statements/class/fields-wrapped-in-sc-static-computed-symbol-names.js @@ -28,6 +28,7 @@ class C { ;;;; ;;;;;;[x]; [y] = 42;;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/statements/class/fields-wrapped-in-sc-static-literal-names.js b/test/language/statements/class/fields-wrapped-in-sc-static-literal-names.js index ef8a81c6ffb40f291816055509b9431e2153bf34..71170aa351842d0a7e7ae272bea868003998e855 100644 --- a/test/language/statements/class/fields-wrapped-in-sc-static-literal-names.js +++ b/test/language/statements/class/fields-wrapped-in-sc-static-literal-names.js @@ -28,6 +28,7 @@ class C { ;;;;;;static a; b = 42; static c = fn;;;;;;; ;;;; + } var c = new C(); diff --git a/test/language/statements/class/fields-wrapped-in-sc-static-private-names.js b/test/language/statements/class/fields-wrapped-in-sc-static-private-names.js new file mode 100644 index 0000000000000000000000000000000000000000..046949b3acb295edb78631e495276e57139d55a7 --- /dev/null +++ b/test/language/statements/class/fields-wrapped-in-sc-static-private-names.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/class-fields/static-private-names.case +// - src/class-fields/default/cls-decl-wrapped-in-sc.template +/*--- +description: literal private names (fields definition wrapped in semicolons) +esid: prod-FieldDefinition +features: [class-fields] +flags: [generated] +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName + +---*/ + + +class C { + ;;;; + ;;;;;;static #x; static #y;;;;;;; + ;;;; +static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +} + +var c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1"); +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2"); +assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3"); + +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5"); +assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6"); + +// Test if private fields can be sucessfully accessed and set to value +assert.sameValue(C.x(), 42, "test 7"); +assert.sameValue(C.y(), 43, "test 8"); + +// Test the private fields do not appear as properties before after set to value +assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9"); +assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10"); diff --git a/test/language/statements/class/fields-wrapped-in-sc-string-literal-names.js b/test/language/statements/class/fields-wrapped-in-sc-string-literal-names.js index 51a4863a699bba858973edc8206d1c4aa2d86d17..84d67296827aad73da905951be01e8074e7daf30 100644 --- a/test/language/statements/class/fields-wrapped-in-sc-string-literal-names.js +++ b/test/language/statements/class/fields-wrapped-in-sc-string-literal-names.js @@ -26,6 +26,7 @@ class C { ;;;;;;'a'; "b"; 'c' = 39; "d" = 42;;;;;;; ;;;; + } var c = new C();