From 214e9969d5d1cb8c019f40d56bb877d28740e0a7 Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Mon, 30 Oct 2017 00:34:05 -0400 Subject: [PATCH 1/3] class fields: added tests for privatename production --- ...ls-decl-after-same-line-async-gen.template | 1 + ...decl-after-same-line-async-method.template | 1 + .../cls-decl-after-same-line-gen.template | 1 + .../cls-decl-after-same-line-method.template | 1 + ...-after-same-line-static-async-gen.template | 1 + ...ter-same-line-static-async-method.template | 1 + ...s-decl-after-same-line-static-gen.template | 1 + ...ecl-after-same-line-static-method.template | 1 + .../cls-decl-multiple-definitions.template | 1 + ...decl-multiple-stacked-definitions.template | 1 + .../cls-decl-new-no-sc-line-method.template | 1 + .../cls-decl-new-sc-line-generator.template | 1 + .../cls-decl-new-sc-line-method.template | 1 + .../cls-decl-regular-definitions.template | 1 + .../cls-decl-same-line-generator.template | 1 + .../cls-decl-same-line-method.template | 1 + .../default/cls-decl-wrapped-in-sc.template | 1 + ...ls-expr-after-same-line-async-gen.template | 1 + ...expr-after-same-line-async-method.template | 1 + .../cls-expr-after-same-line-gen.template | 1 + .../cls-expr-after-same-line-method.template | 1 + ...-after-same-line-static-async-gen.template | 1 + ...ter-same-line-static-async-method.template | 1 + ...s-expr-after-same-line-static-gen.template | 1 + ...xpr-after-same-line-static-method.template | 1 + .../cls-expr-multiple-definitions.template | 1 + ...expr-multiple-stacked-definitions.template | 1 + .../cls-expr-new-no-sc-line-method.template | 1 + .../cls-expr-new-sc-line-generator.template | 1 + .../cls-expr-new-sc-line-method.template | 1 + .../cls-expr-regular-definitions.template | 1 + .../cls-expr-same-line-generator.template | 1 + .../cls-expr-same-line-method.template | 1 + .../default/cls-expr-wrapped-in-sc.template | 1 + src/class-fields/private-names.case | 50 +++++++++++++++++++ src/class-fields/static-private-names.case | 50 +++++++++++++++++++ 36 files changed, 134 insertions(+) create mode 100644 src/class-fields/private-names.case create mode 100644 src/class-fields/static-private-names.case diff --git a/src/class-fields/default/cls-decl-after-same-line-async-gen.template b/src/class-fields/default/cls-decl-after-same-line-async-gen.template index 0e8b27edce..2b7019564c 100644 --- a/src/class-fields/default/cls-decl-after-same-line-async-gen.template +++ b/src/class-fields/default/cls-decl-after-same-line-async-gen.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition class C { async *m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-after-same-line-async-method.template b/src/class-fields/default/cls-decl-after-same-line-async-method.template index 531c7f835b..4834b53fc5 100644 --- a/src/class-fields/default/cls-decl-after-same-line-async-method.template +++ b/src/class-fields/default/cls-decl-after-same-line-async-method.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition class C { async m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-after-same-line-gen.template b/src/class-fields/default/cls-decl-after-same-line-gen.template index 876e0d8c5a..635294c5df 100644 --- a/src/class-fields/default/cls-decl-after-same-line-gen.template +++ b/src/class-fields/default/cls-decl-after-same-line-gen.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition class C { *m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-after-same-line-method.template b/src/class-fields/default/cls-decl-after-same-line-method.template index 5e8dffcbd2..3ad70efd6f 100644 --- a/src/class-fields/default/cls-decl-after-same-line-method.template +++ b/src/class-fields/default/cls-decl-after-same-line-method.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition class C { m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-after-same-line-static-async-gen.template b/src/class-fields/default/cls-decl-after-same-line-static-async-gen.template index 223bfd3455..60176379ae 100644 --- a/src/class-fields/default/cls-decl-after-same-line-static-async-gen.template +++ b/src/class-fields/default/cls-decl-after-same-line-static-async-gen.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition class C { static async *m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-after-same-line-static-async-method.template b/src/class-fields/default/cls-decl-after-same-line-static-async-method.template index 70e6085c1d..360df4a7f9 100644 --- a/src/class-fields/default/cls-decl-after-same-line-static-async-method.template +++ b/src/class-fields/default/cls-decl-after-same-line-static-async-method.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition class C { static async m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-after-same-line-static-gen.template b/src/class-fields/default/cls-decl-after-same-line-static-gen.template index d89d9975a2..2a9fdff3a0 100644 --- a/src/class-fields/default/cls-decl-after-same-line-static-gen.template +++ b/src/class-fields/default/cls-decl-after-same-line-static-gen.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition class C { static *m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-after-same-line-static-method.template b/src/class-fields/default/cls-decl-after-same-line-static-method.template index 0f412da85b..568b3c5647 100644 --- a/src/class-fields/default/cls-decl-after-same-line-static-method.template +++ b/src/class-fields/default/cls-decl-after-same-line-static-method.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition class C { static m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-multiple-definitions.template b/src/class-fields/default/cls-decl-multiple-definitions.template index e481f94dda..5671a0b6c4 100644 --- a/src/class-fields/default/cls-decl-multiple-definitions.template +++ b/src/class-fields/default/cls-decl-multiple-definitions.template @@ -14,6 +14,7 @@ class C { /*{ fields }*/ m2() { return 39 } bar = "barbaz"; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-multiple-stacked-definitions.template b/src/class-fields/default/cls-decl-multiple-stacked-definitions.template index 6a16f68f96..36515109ea 100644 --- a/src/class-fields/default/cls-decl-multiple-stacked-definitions.template +++ b/src/class-fields/default/cls-decl-multiple-stacked-definitions.template @@ -12,6 +12,7 @@ class C { /*{ fields }*/ foo = "foobar" bar = "barbaz"; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-new-no-sc-line-method.template b/src/class-fields/default/cls-decl-new-no-sc-line-method.template index d87e9152e9..56037a513a 100644 --- a/src/class-fields/default/cls-decl-new-no-sc-line-method.template +++ b/src/class-fields/default/cls-decl-new-no-sc-line-method.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition class C { /*{ fields }*/ m() { return 42; } +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-new-sc-line-generator.template b/src/class-fields/default/cls-decl-new-sc-line-generator.template index 3be29af985..40098a7810 100644 --- a/src/class-fields/default/cls-decl-new-sc-line-generator.template +++ b/src/class-fields/default/cls-decl-new-sc-line-generator.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition class C { /*{ fields }*/; *m() { return 42; } +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-new-sc-line-method.template b/src/class-fields/default/cls-decl-new-sc-line-method.template index 640244370a..6f56356466 100644 --- a/src/class-fields/default/cls-decl-new-sc-line-method.template +++ b/src/class-fields/default/cls-decl-new-sc-line-method.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition class C { /*{ fields }*/; m() { return 42; } +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-regular-definitions.template b/src/class-fields/default/cls-decl-regular-definitions.template index 9d1ee0c283..4ccdd76f7f 100644 --- a/src/class-fields/default/cls-decl-regular-definitions.template +++ b/src/class-fields/default/cls-decl-regular-definitions.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition class C { /*{ fields }*/ +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-same-line-generator.template b/src/class-fields/default/cls-decl-same-line-generator.template index 1c4fa07d71..182d9df50d 100644 --- a/src/class-fields/default/cls-decl-same-line-generator.template +++ b/src/class-fields/default/cls-decl-same-line-generator.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition class C { /*{ fields }*/; *m() { return 42; } +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-same-line-method.template b/src/class-fields/default/cls-decl-same-line-method.template index 2a825bee8b..c94c864bdd 100644 --- a/src/class-fields/default/cls-decl-same-line-method.template +++ b/src/class-fields/default/cls-decl-same-line-method.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition class C { /*{ fields }*/; m() { return 42; } +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-decl-wrapped-in-sc.template b/src/class-fields/default/cls-decl-wrapped-in-sc.template index 5d04a5622e..b76403262a 100644 --- a/src/class-fields/default/cls-decl-wrapped-in-sc.template +++ b/src/class-fields/default/cls-decl-wrapped-in-sc.template @@ -12,6 +12,7 @@ class C { ;;;; ;;;;;;/*{ fields }*/;;;;;;; ;;;; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-after-same-line-async-gen.template b/src/class-fields/default/cls-expr-after-same-line-async-gen.template index cb27c785c8..3a1a6f4630 100644 --- a/src/class-fields/default/cls-expr-after-same-line-async-gen.template +++ b/src/class-fields/default/cls-expr-after-same-line-async-gen.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition var C = class { async *m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-after-same-line-async-method.template b/src/class-fields/default/cls-expr-after-same-line-async-method.template index eafc614d7b..87c137ce2d 100644 --- a/src/class-fields/default/cls-expr-after-same-line-async-method.template +++ b/src/class-fields/default/cls-expr-after-same-line-async-method.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition var C = class { async m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-after-same-line-gen.template b/src/class-fields/default/cls-expr-after-same-line-gen.template index 07e7a485d6..58aa427d3a 100644 --- a/src/class-fields/default/cls-expr-after-same-line-gen.template +++ b/src/class-fields/default/cls-expr-after-same-line-gen.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition var C = class { *m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-after-same-line-method.template b/src/class-fields/default/cls-expr-after-same-line-method.template index 70fca8fe22..d9e6703d6a 100644 --- a/src/class-fields/default/cls-expr-after-same-line-method.template +++ b/src/class-fields/default/cls-expr-after-same-line-method.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition var C = class { m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-after-same-line-static-async-gen.template b/src/class-fields/default/cls-expr-after-same-line-static-async-gen.template index 1f34b5cf87..f19896d7af 100644 --- a/src/class-fields/default/cls-expr-after-same-line-static-async-gen.template +++ b/src/class-fields/default/cls-expr-after-same-line-static-async-gen.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition var C = class { static async *m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-after-same-line-static-async-method.template b/src/class-fields/default/cls-expr-after-same-line-static-async-method.template index e4a9657d77..0b0ae19ec4 100644 --- a/src/class-fields/default/cls-expr-after-same-line-static-async-method.template +++ b/src/class-fields/default/cls-expr-after-same-line-static-async-method.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition var C = class { static async m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-after-same-line-static-gen.template b/src/class-fields/default/cls-expr-after-same-line-static-gen.template index c64467527d..1eff6019a1 100644 --- a/src/class-fields/default/cls-expr-after-same-line-static-gen.template +++ b/src/class-fields/default/cls-expr-after-same-line-static-gen.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition var C = class { static *m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-after-same-line-static-method.template b/src/class-fields/default/cls-expr-after-same-line-static-method.template index 56f677a9bf..1621379473 100644 --- a/src/class-fields/default/cls-expr-after-same-line-static-method.template +++ b/src/class-fields/default/cls-expr-after-same-line-static-method.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition var C = class { static m() { return 42; } /*{ fields }*/; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-multiple-definitions.template b/src/class-fields/default/cls-expr-multiple-definitions.template index 543b9f2b0f..8a786bf9e5 100644 --- a/src/class-fields/default/cls-expr-multiple-definitions.template +++ b/src/class-fields/default/cls-expr-multiple-definitions.template @@ -14,6 +14,7 @@ var C = class { /*{ fields }*/ m2() { return 39 } bar = "barbaz"; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-multiple-stacked-definitions.template b/src/class-fields/default/cls-expr-multiple-stacked-definitions.template index 6bf9a746f5..a1c53aee19 100644 --- a/src/class-fields/default/cls-expr-multiple-stacked-definitions.template +++ b/src/class-fields/default/cls-expr-multiple-stacked-definitions.template @@ -12,6 +12,7 @@ var C = class { /*{ fields }*/ foo = "foobar" bar = "barbaz"; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-new-no-sc-line-method.template b/src/class-fields/default/cls-expr-new-no-sc-line-method.template index 88045824da..50e6762ada 100644 --- a/src/class-fields/default/cls-expr-new-no-sc-line-method.template +++ b/src/class-fields/default/cls-expr-new-no-sc-line-method.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition var C = class { /*{ fields }*/ m() { return 42; } +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-new-sc-line-generator.template b/src/class-fields/default/cls-expr-new-sc-line-generator.template index 022c5b8ffa..1433173685 100644 --- a/src/class-fields/default/cls-expr-new-sc-line-generator.template +++ b/src/class-fields/default/cls-expr-new-sc-line-generator.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition var C = class { /*{ fields }*/; *m() { return 42; } +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-new-sc-line-method.template b/src/class-fields/default/cls-expr-new-sc-line-method.template index 04cc5d7f1b..3e7291ad66 100644 --- a/src/class-fields/default/cls-expr-new-sc-line-method.template +++ b/src/class-fields/default/cls-expr-new-sc-line-method.template @@ -11,6 +11,7 @@ esid: prod-FieldDefinition var C = class { /*{ fields }*/; m() { return 42; } +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-regular-definitions.template b/src/class-fields/default/cls-expr-regular-definitions.template index 65cea698c7..630c04f41c 100644 --- a/src/class-fields/default/cls-expr-regular-definitions.template +++ b/src/class-fields/default/cls-expr-regular-definitions.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition var C = class { /*{ fields }*/ +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-same-line-generator.template b/src/class-fields/default/cls-expr-same-line-generator.template index b85431604a..c6ee64851f 100644 --- a/src/class-fields/default/cls-expr-same-line-generator.template +++ b/src/class-fields/default/cls-expr-same-line-generator.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition var C = class { /*{ fields }*/; *m() { return 42; } +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-same-line-method.template b/src/class-fields/default/cls-expr-same-line-method.template index 2b06fe7329..4c9602cafc 100644 --- a/src/class-fields/default/cls-expr-same-line-method.template +++ b/src/class-fields/default/cls-expr-same-line-method.template @@ -10,6 +10,7 @@ esid: prod-FieldDefinition var C = class { /*{ fields }*/; m() { return 42; } +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/default/cls-expr-wrapped-in-sc.template b/src/class-fields/default/cls-expr-wrapped-in-sc.template index 6646d1b4c1..4f7397057f 100644 --- a/src/class-fields/default/cls-expr-wrapped-in-sc.template +++ b/src/class-fields/default/cls-expr-wrapped-in-sc.template @@ -12,6 +12,7 @@ var C = class { ;;;; ;;;;;;/*{ fields }*/;;;;;;; ;;;; +/*{ privateinspectionfunctions }*/ } var c = new C(); diff --git a/src/class-fields/private-names.case b/src/class-fields/private-names.case new file mode 100644 index 0000000000..6987bcd7b2 --- /dev/null +++ b/src/class-fields/private-names.case @@ -0,0 +1,50 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: static literal private names +info: | + ClassElement: + ... + FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName +template: default +---*/ + +//- fields +#x; #y +//- privateinspectionfunctions + x() { + this.#x = 42; + return this.#x; + } + y() { + this.#y = 43; + return this.#y; + } +//- assertions + +// 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/src/class-fields/static-private-names.case b/src/class-fields/static-private-names.case new file mode 100644 index 0000000000..464b53a9e9 --- /dev/null +++ b/src/class-fields/static-private-names.case @@ -0,0 +1,50 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: literal private names +info: | + ClassElement: + ... + static FieldDefinition ; + + FieldDefinition: + ClassElementName Initializer_opt + + ClassElementName: + PrivateName + + PrivateName: + #IdentifierName +template: default +---*/ + +//- fields +static #x; static #y +//- privateinspectionfunctions + static x() { + this.#x = 42; + return this.#x; + } + static y() { + this.#y = 43; + return this.#y; + } +//- assertions + +// 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"); From dd371194fed81ace9a38f8ff9f4682e6d0acc483 Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Mon, 30 Oct 2017 12:43:37 -0400 Subject: [PATCH 2/3] class fields: add ASI tests --- .../expressions/class/fields-asi-1.js | 19 +++++++++++++ .../expressions/class/fields-asi-2.js | 17 +++++++++++ .../expressions/class/fields-asi-3.js | 18 ++++++++++++ .../expressions/class/fields-asi-4.js | 18 ++++++++++++ .../expressions/class/fields-asi-5.js | 28 +++++++++++++++++++ .../language/statements/class/fields-asi-1.js | 19 +++++++++++++ .../language/statements/class/fields-asi-2.js | 17 +++++++++++ .../language/statements/class/fields-asi-3.js | 18 ++++++++++++ .../language/statements/class/fields-asi-4.js | 18 ++++++++++++ .../language/statements/class/fields-asi-5.js | 27 ++++++++++++++++++ 10 files changed, 199 insertions(+) create mode 100644 test/language/expressions/class/fields-asi-1.js create mode 100644 test/language/expressions/class/fields-asi-2.js create mode 100644 test/language/expressions/class/fields-asi-3.js create mode 100644 test/language/expressions/class/fields-asi-4.js create mode 100644 test/language/expressions/class/fields-asi-5.js create mode 100644 test/language/statements/class/fields-asi-1.js create mode 100644 test/language/statements/class/fields-asi-2.js create mode 100644 test/language/statements/class/fields-asi-3.js create mode 100644 test/language/statements/class/fields-asi-4.js create mode 100644 test/language/statements/class/fields-asi-5.js diff --git a/test/language/expressions/class/fields-asi-1.js b/test/language/expressions/class/fields-asi-1.js new file mode 100644 index 0000000000..aed503ba6c --- /dev/null +++ b/test/language/expressions/class/fields-asi-1.js @@ -0,0 +1,19 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- computed name interpreted as property +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +var obj = {} +var C = class { + x = obj + ['lol'] = 42 +} + +var c = new C(); + +assert.sameValue(c.x, 42) +assert.sameValue(obj['lol'], 42); diff --git a/test/language/expressions/class/fields-asi-2.js b/test/language/expressions/class/fields-asi-2.js new file mode 100644 index 0000000000..bc153cd8cc --- /dev/null +++ b/test/language/expressions/class/fields-asi-2.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- computed name interpreted as string index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +var C = class { + x = "lol" + [1] +} + +var c = new C(); + +assert.sameValue(c.x, 'o'); diff --git a/test/language/expressions/class/fields-asi-3.js b/test/language/expressions/class/fields-asi-3.js new file mode 100644 index 0000000000..256a257d53 --- /dev/null +++ b/test/language/expressions/class/fields-asi-3.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when computed name interpreted as index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +negative: + phase: early + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class { + x = "string" + [0]() {} +} diff --git a/test/language/expressions/class/fields-asi-4.js b/test/language/expressions/class/fields-asi-4.js new file mode 100644 index 0000000000..1e0edec706 --- /dev/null +++ b/test/language/expressions/class/fields-asi-4.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when generator interpreted as multiplication +esid: sec-automatic-semicolon-insertion +features: [class-fields] +negative: + phase: early + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class { + x = 42 + *gen() {} +} diff --git a/test/language/expressions/class/fields-asi-5.js b/test/language/expressions/class/fields-asi-5.js new file mode 100644 index 0000000000..a57fd2bb9b --- /dev/null +++ b/test/language/expressions/class/fields-asi-5.js @@ -0,0 +1,28 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- field with PropertyName "in" interpreted as index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +var x = 1 +var y = 2 +var z = [42] + +var C = class { + a = x + in + z + b = y + in + z +} + +var c = new C(); + +assert.sameValue(c.a, true, 'a = x in z') +assert.sameValue(c.a, false, 'a = y in z') +assert.sameValue(Object.hasOwnProperty.call(c, "in"), false, "'in' interpreted as index"); +assert.sameValue(Object.hasOwnProperty.call(c, "z"), false, "'z' interpreted as variable"); diff --git a/test/language/statements/class/fields-asi-1.js b/test/language/statements/class/fields-asi-1.js new file mode 100644 index 0000000000..56a9dda58b --- /dev/null +++ b/test/language/statements/class/fields-asi-1.js @@ -0,0 +1,19 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- computed name interpreted as property +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +var obj = {} +class C { + x = obj + ['lol'] = 42 +} + +var c = new C(); + +assert.sameValue(c.x, 42); +assert.sameValue(obj['lol'], 42); diff --git a/test/language/statements/class/fields-asi-2.js b/test/language/statements/class/fields-asi-2.js new file mode 100644 index 0000000000..70488e9e66 --- /dev/null +++ b/test/language/statements/class/fields-asi-2.js @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- computed name interpreted as string index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +class C { + x = "lol" + [1] +} + +var c = new C(); + +assert.sameValue(c.x, 'o'); diff --git a/test/language/statements/class/fields-asi-3.js b/test/language/statements/class/fields-asi-3.js new file mode 100644 index 0000000000..42f49fd1e1 --- /dev/null +++ b/test/language/statements/class/fields-asi-3.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when computed name interpreted as index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +negative: + phase: early + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +class C { + x = "string" + [0]() {} +} diff --git a/test/language/statements/class/fields-asi-4.js b/test/language/statements/class/fields-asi-4.js new file mode 100644 index 0000000000..c1506f34f8 --- /dev/null +++ b/test/language/statements/class/fields-asi-4.js @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- error when generator interpreted as multiplication +esid: sec-automatic-semicolon-insertion +features: [class-fields] +negative: + phase: early + type: SyntaxError +---*/ + +throw "Test262: This statement should not be evaluated."; + +class C { + x = 42 + *gen() {} +} diff --git a/test/language/statements/class/fields-asi-5.js b/test/language/statements/class/fields-asi-5.js new file mode 100644 index 0000000000..86bc18f882 --- /dev/null +++ b/test/language/statements/class/fields-asi-5.js @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: ASI test in field declarations -- field with PropertyName "in" interpreted as index +esid: sec-automatic-semicolon-insertion +features: [class-fields] +---*/ + +var x = 1 +var y = 2 +var z = [42] + +class C { + a = x + in + z + b = y + in + z +} + +var c = new C(); +assert.sameValue(c.a, true, 'a = x in z') +assert.sameValue(c.a, false, 'a = y in z') +assert.sameValue(Object.hasOwnProperty.call(c, "in"), false, "'in' interpreted as index"); +assert.sameValue(Object.hasOwnProperty.call(c, "z"), false, "'z' interpreted as variable"); From 1bbedf4b02e43a5a49b8ce6fa9509f6b06cdb1b9 Mon Sep 17 00:00:00 2001 From: Valerie R Young Date: Mon, 30 Oct 2017 00:39:14 -0400 Subject: [PATCH 3/3] regenerate files --- ...elds-after-same-line-gen-computed-names.js | 1 + ...ter-same-line-gen-computed-symbol-names.js | 1 + ...ields-after-same-line-gen-literal-names.js | 1 + ...ields-after-same-line-gen-private-names.js | 65 +++++++++++ ...ter-same-line-gen-static-computed-names.js | 1 + ...e-line-gen-static-computed-symbol-names.js | 1 + ...fter-same-line-gen-static-literal-names.js | 1 + ...fter-same-line-gen-static-private-names.js | 65 +++++++++++ ...fter-same-line-gen-string-literal-names.js | 1 + ...s-after-same-line-method-computed-names.js | 1 + ...-same-line-method-computed-symbol-names.js | 1 + ...ds-after-same-line-method-literal-names.js | 1 + ...ds-after-same-line-method-private-names.js | 65 +++++++++++ ...-same-line-method-static-computed-names.js | 1 + ...ine-method-static-computed-symbol-names.js | 1 + ...r-same-line-method-static-literal-names.js | 1 + ...r-same-line-method-static-private-names.js | 65 +++++++++++ ...r-same-line-method-string-literal-names.js | 1 + ...me-line-static-async-gen-computed-names.js | 1 + ...-static-async-gen-computed-symbol-names.js | 1 + ...ame-line-static-async-gen-literal-names.js | 1 + ...ame-line-static-async-gen-private-names.js | 69 ++++++++++++ ...-static-async-gen-static-computed-names.js | 1 + ...-async-gen-static-computed-symbol-names.js | 1 + ...e-static-async-gen-static-literal-names.js | 1 + ...e-static-async-gen-static-private-names.js | 69 ++++++++++++ ...e-static-async-gen-string-literal-names.js | 1 + ...line-static-async-method-computed-names.js | 1 + ...atic-async-method-computed-symbol-names.js | 1 + ...-line-static-async-method-literal-names.js | 1 + ...-line-static-async-method-private-names.js | 68 ++++++++++++ ...atic-async-method-static-computed-names.js | 1 + ...ync-method-static-computed-symbol-names.js | 1 + ...tatic-async-method-static-literal-names.js | 1 + ...tatic-async-method-static-private-names.js | 68 ++++++++++++ ...tatic-async-method-string-literal-names.js | 1 + ...ter-same-line-static-gen-computed-names.js | 1 + ...e-line-static-gen-computed-symbol-names.js | 1 + ...fter-same-line-static-gen-literal-names.js | 1 + ...fter-same-line-static-gen-private-names.js | 65 +++++++++++ ...e-line-static-gen-static-computed-names.js | 1 + ...static-gen-static-computed-symbol-names.js | 1 + ...me-line-static-gen-static-literal-names.js | 1 + ...me-line-static-gen-static-private-names.js | 65 +++++++++++ ...me-line-static-gen-string-literal-names.js | 1 + ...-same-line-static-method-computed-names.js | 1 + ...ine-static-method-computed-symbol-names.js | 1 + ...r-same-line-static-method-literal-names.js | 1 + ...r-same-line-static-method-private-names.js | 65 +++++++++++ ...ine-static-method-static-computed-names.js | 1 + ...tic-method-static-computed-symbol-names.js | 1 + ...line-static-method-static-literal-names.js | 1 + ...line-static-method-static-private-names.js | 65 +++++++++++ ...line-static-method-string-literal-names.js | 1 + ...lds-multiple-definitions-computed-names.js | 1 + ...tiple-definitions-computed-symbol-names.js | 1 + ...elds-multiple-definitions-literal-names.js | 1 + ...elds-multiple-definitions-private-names.js | 101 ++++++++++++++++++ ...tiple-definitions-static-computed-names.js | 1 + ...efinitions-static-computed-symbol-names.js | 1 + ...ltiple-definitions-static-literal-names.js | 1 + ...ltiple-definitions-static-private-names.js | 101 ++++++++++++++++++ ...ltiple-definitions-string-literal-names.js | 1 + ...iple-stacked-definitions-computed-names.js | 1 + ...acked-definitions-computed-symbol-names.js | 1 + ...tiple-stacked-definitions-literal-names.js | 1 + ...tiple-stacked-definitions-private-names.js | 79 ++++++++++++++ ...acked-definitions-static-computed-names.js | 1 + ...efinitions-static-computed-symbol-names.js | 1 + ...tacked-definitions-static-literal-names.js | 1 + ...tacked-definitions-static-private-names.js | 79 ++++++++++++++ ...tacked-definitions-string-literal-names.js | 1 + ...ds-new-no-sc-line-method-computed-names.js | 1 + ...no-sc-line-method-computed-symbol-names.js | 1 + ...lds-new-no-sc-line-method-literal-names.js | 1 + ...lds-new-no-sc-line-method-private-names.js | 66 ++++++++++++ ...no-sc-line-method-static-computed-names.js | 1 + ...ine-method-static-computed-symbol-names.js | 1 + ...-no-sc-line-method-static-literal-names.js | 1 + ...-no-sc-line-method-static-private-names.js | 66 ++++++++++++ ...-no-sc-line-method-string-literal-names.js | 1 + .../fields-new-sc-line-gen-computed-names.js | 1 + ...s-new-sc-line-gen-computed-symbol-names.js | 1 + .../fields-new-sc-line-gen-literal-names.js | 1 + .../fields-new-sc-line-gen-private-names.js | 66 ++++++++++++ ...s-new-sc-line-gen-static-computed-names.js | 1 + ...c-line-gen-static-computed-symbol-names.js | 1 + ...ds-new-sc-line-gen-static-literal-names.js | 1 + ...ds-new-sc-line-gen-static-private-names.js | 66 ++++++++++++ ...ds-new-sc-line-gen-string-literal-names.js | 1 + ...ields-new-sc-line-method-computed-names.js | 1 + ...ew-sc-line-method-computed-symbol-names.js | 1 + ...fields-new-sc-line-method-literal-names.js | 1 + ...fields-new-sc-line-method-private-names.js | 66 ++++++++++++ ...ew-sc-line-method-static-computed-names.js | 1 + ...ine-method-static-computed-symbol-names.js | 1 + ...new-sc-line-method-static-literal-names.js | 1 + ...new-sc-line-method-static-private-names.js | 66 ++++++++++++ ...new-sc-line-method-string-literal-names.js | 1 + ...elds-regular-definitions-computed-names.js | 1 + ...gular-definitions-computed-symbol-names.js | 1 + ...ields-regular-definitions-literal-names.js | 1 + ...ields-regular-definitions-private-names.js | 55 ++++++++++ ...gular-definitions-static-computed-names.js | 1 + ...efinitions-static-computed-symbol-names.js | 1 + ...egular-definitions-static-literal-names.js | 1 + ...egular-definitions-static-private-names.js | 55 ++++++++++ ...egular-definitions-string-literal-names.js | 1 + ...elds-same-line-async-gen-computed-names.js | 1 + ...me-line-async-gen-computed-symbol-names.js | 1 + ...ields-same-line-async-gen-literal-names.js | 1 + ...ields-same-line-async-gen-private-names.js | 69 ++++++++++++ ...me-line-async-gen-static-computed-names.js | 1 + ...-async-gen-static-computed-symbol-names.js | 1 + ...ame-line-async-gen-static-literal-names.js | 1 + ...ame-line-async-gen-static-private-names.js | 69 ++++++++++++ ...ame-line-async-gen-string-literal-names.js | 1 + ...s-same-line-async-method-computed-names.js | 1 + ...line-async-method-computed-symbol-names.js | 1 + ...ds-same-line-async-method-literal-names.js | 1 + ...ds-same-line-async-method-private-names.js | 68 ++++++++++++ ...line-async-method-static-computed-names.js | 1 + ...ync-method-static-computed-symbol-names.js | 1 + ...-line-async-method-static-literal-names.js | 1 + ...-line-async-method-static-private-names.js | 68 ++++++++++++ ...-line-async-method-string-literal-names.js | 1 + .../fields-same-line-gen-computed-names.js | 1 + ...lds-same-line-gen-computed-symbol-names.js | 1 + .../fields-same-line-gen-literal-names.js | 1 + .../fields-same-line-gen-private-names.js | 65 +++++++++++ ...lds-same-line-gen-static-computed-names.js | 1 + ...e-line-gen-static-computed-symbol-names.js | 1 + ...elds-same-line-gen-static-literal-names.js | 1 + ...elds-same-line-gen-static-private-names.js | 65 +++++++++++ ...elds-same-line-gen-string-literal-names.js | 1 + .../fields-same-line-method-computed-names.js | 1 + ...-same-line-method-computed-symbol-names.js | 1 + .../fields-same-line-method-literal-names.js | 1 + .../fields-same-line-method-private-names.js | 65 +++++++++++ ...-same-line-method-static-computed-names.js | 1 + ...ine-method-static-computed-symbol-names.js | 1 + ...s-same-line-method-static-literal-names.js | 1 + ...s-same-line-method-static-private-names.js | 65 +++++++++++ ...s-same-line-method-string-literal-names.js | 1 + .../fields-wrapped-in-sc-computed-names.js | 1 + ...lds-wrapped-in-sc-computed-symbol-names.js | 1 + .../fields-wrapped-in-sc-literal-names.js | 1 + .../fields-wrapped-in-sc-private-names.js | 57 ++++++++++ ...lds-wrapped-in-sc-static-computed-names.js | 1 + ...pped-in-sc-static-computed-symbol-names.js | 1 + ...elds-wrapped-in-sc-static-literal-names.js | 1 + ...elds-wrapped-in-sc-static-private-names.js | 57 ++++++++++ ...elds-wrapped-in-sc-string-literal-names.js | 1 + ...elds-after-same-line-gen-computed-names.js | 1 + ...ter-same-line-gen-computed-symbol-names.js | 1 + ...ields-after-same-line-gen-literal-names.js | 1 + ...ields-after-same-line-gen-private-names.js | 65 +++++++++++ ...ter-same-line-gen-static-computed-names.js | 1 + ...e-line-gen-static-computed-symbol-names.js | 1 + ...fter-same-line-gen-static-literal-names.js | 1 + ...fter-same-line-gen-static-private-names.js | 65 +++++++++++ ...fter-same-line-gen-string-literal-names.js | 1 + ...s-after-same-line-method-computed-names.js | 1 + ...-same-line-method-computed-symbol-names.js | 1 + ...ds-after-same-line-method-literal-names.js | 1 + ...ds-after-same-line-method-private-names.js | 65 +++++++++++ ...-same-line-method-static-computed-names.js | 1 + ...ine-method-static-computed-symbol-names.js | 1 + ...r-same-line-method-static-literal-names.js | 1 + ...r-same-line-method-static-private-names.js | 65 +++++++++++ ...r-same-line-method-string-literal-names.js | 1 + ...me-line-static-async-gen-computed-names.js | 1 + ...-static-async-gen-computed-symbol-names.js | 1 + ...ame-line-static-async-gen-literal-names.js | 1 + ...ame-line-static-async-gen-private-names.js | 69 ++++++++++++ ...-static-async-gen-static-computed-names.js | 1 + ...-async-gen-static-computed-symbol-names.js | 1 + ...e-static-async-gen-static-literal-names.js | 1 + ...e-static-async-gen-static-private-names.js | 69 ++++++++++++ ...e-static-async-gen-string-literal-names.js | 1 + ...line-static-async-method-computed-names.js | 1 + ...atic-async-method-computed-symbol-names.js | 1 + ...-line-static-async-method-literal-names.js | 1 + ...-line-static-async-method-private-names.js | 68 ++++++++++++ ...atic-async-method-static-computed-names.js | 1 + ...ync-method-static-computed-symbol-names.js | 1 + ...tatic-async-method-static-literal-names.js | 1 + ...tatic-async-method-static-private-names.js | 68 ++++++++++++ ...tatic-async-method-string-literal-names.js | 1 + ...ter-same-line-static-gen-computed-names.js | 1 + ...e-line-static-gen-computed-symbol-names.js | 1 + ...fter-same-line-static-gen-literal-names.js | 1 + ...fter-same-line-static-gen-private-names.js | 65 +++++++++++ ...e-line-static-gen-static-computed-names.js | 1 + ...static-gen-static-computed-symbol-names.js | 1 + ...me-line-static-gen-static-literal-names.js | 1 + ...me-line-static-gen-static-private-names.js | 65 +++++++++++ ...me-line-static-gen-string-literal-names.js | 1 + ...-same-line-static-method-computed-names.js | 1 + ...ine-static-method-computed-symbol-names.js | 1 + ...r-same-line-static-method-literal-names.js | 1 + ...r-same-line-static-method-private-names.js | 65 +++++++++++ ...ine-static-method-static-computed-names.js | 1 + ...tic-method-static-computed-symbol-names.js | 1 + ...line-static-method-static-literal-names.js | 1 + ...line-static-method-static-private-names.js | 65 +++++++++++ ...line-static-method-string-literal-names.js | 1 + ...lds-multiple-definitions-computed-names.js | 1 + ...tiple-definitions-computed-symbol-names.js | 1 + ...elds-multiple-definitions-literal-names.js | 1 + ...elds-multiple-definitions-private-names.js | 101 ++++++++++++++++++ ...tiple-definitions-static-computed-names.js | 1 + ...efinitions-static-computed-symbol-names.js | 1 + ...ltiple-definitions-static-literal-names.js | 1 + ...ltiple-definitions-static-private-names.js | 101 ++++++++++++++++++ ...ltiple-definitions-string-literal-names.js | 1 + ...iple-stacked-definitions-computed-names.js | 1 + ...acked-definitions-computed-symbol-names.js | 1 + ...tiple-stacked-definitions-literal-names.js | 1 + ...tiple-stacked-definitions-private-names.js | 79 ++++++++++++++ ...acked-definitions-static-computed-names.js | 1 + ...efinitions-static-computed-symbol-names.js | 1 + ...tacked-definitions-static-literal-names.js | 1 + ...tacked-definitions-static-private-names.js | 79 ++++++++++++++ ...tacked-definitions-string-literal-names.js | 1 + ...ds-new-no-sc-line-method-computed-names.js | 1 + ...no-sc-line-method-computed-symbol-names.js | 1 + ...lds-new-no-sc-line-method-literal-names.js | 1 + ...lds-new-no-sc-line-method-private-names.js | 66 ++++++++++++ ...no-sc-line-method-static-computed-names.js | 1 + ...ine-method-static-computed-symbol-names.js | 1 + ...-no-sc-line-method-static-literal-names.js | 1 + ...-no-sc-line-method-static-private-names.js | 66 ++++++++++++ ...-no-sc-line-method-string-literal-names.js | 1 + .../fields-new-sc-line-gen-computed-names.js | 1 + ...s-new-sc-line-gen-computed-symbol-names.js | 1 + .../fields-new-sc-line-gen-literal-names.js | 1 + .../fields-new-sc-line-gen-private-names.js | 66 ++++++++++++ ...s-new-sc-line-gen-static-computed-names.js | 1 + ...c-line-gen-static-computed-symbol-names.js | 1 + ...ds-new-sc-line-gen-static-literal-names.js | 1 + ...ds-new-sc-line-gen-static-private-names.js | 66 ++++++++++++ ...ds-new-sc-line-gen-string-literal-names.js | 1 + ...ields-new-sc-line-method-computed-names.js | 1 + ...ew-sc-line-method-computed-symbol-names.js | 1 + ...fields-new-sc-line-method-literal-names.js | 1 + ...fields-new-sc-line-method-private-names.js | 66 ++++++++++++ ...ew-sc-line-method-static-computed-names.js | 1 + ...ine-method-static-computed-symbol-names.js | 1 + ...new-sc-line-method-static-literal-names.js | 1 + ...new-sc-line-method-static-private-names.js | 66 ++++++++++++ ...new-sc-line-method-string-literal-names.js | 1 + ...elds-regular-definitions-computed-names.js | 1 + ...gular-definitions-computed-symbol-names.js | 1 + ...ields-regular-definitions-literal-names.js | 1 + ...ields-regular-definitions-private-names.js | 55 ++++++++++ ...gular-definitions-static-computed-names.js | 1 + ...efinitions-static-computed-symbol-names.js | 1 + ...egular-definitions-static-literal-names.js | 1 + ...egular-definitions-static-private-names.js | 55 ++++++++++ ...egular-definitions-string-literal-names.js | 1 + ...elds-same-line-async-gen-computed-names.js | 1 + ...me-line-async-gen-computed-symbol-names.js | 1 + ...ields-same-line-async-gen-literal-names.js | 1 + ...ields-same-line-async-gen-private-names.js | 69 ++++++++++++ ...me-line-async-gen-static-computed-names.js | 1 + ...-async-gen-static-computed-symbol-names.js | 1 + ...ame-line-async-gen-static-literal-names.js | 1 + ...ame-line-async-gen-static-private-names.js | 69 ++++++++++++ ...ame-line-async-gen-string-literal-names.js | 1 + ...s-same-line-async-method-computed-names.js | 1 + ...line-async-method-computed-symbol-names.js | 1 + ...ds-same-line-async-method-literal-names.js | 1 + ...ds-same-line-async-method-private-names.js | 68 ++++++++++++ ...line-async-method-static-computed-names.js | 1 + ...ync-method-static-computed-symbol-names.js | 1 + ...-line-async-method-static-literal-names.js | 1 + ...-line-async-method-static-private-names.js | 68 ++++++++++++ ...-line-async-method-string-literal-names.js | 1 + .../fields-same-line-gen-computed-names.js | 1 + ...lds-same-line-gen-computed-symbol-names.js | 1 + .../fields-same-line-gen-literal-names.js | 1 + .../fields-same-line-gen-private-names.js | 65 +++++++++++ ...lds-same-line-gen-static-computed-names.js | 1 + ...e-line-gen-static-computed-symbol-names.js | 1 + ...elds-same-line-gen-static-literal-names.js | 1 + ...elds-same-line-gen-static-private-names.js | 65 +++++++++++ ...elds-same-line-gen-string-literal-names.js | 1 + .../fields-same-line-method-computed-names.js | 1 + ...-same-line-method-computed-symbol-names.js | 1 + .../fields-same-line-method-literal-names.js | 1 + .../fields-same-line-method-private-names.js | 65 +++++++++++ ...-same-line-method-static-computed-names.js | 1 + ...ine-method-static-computed-symbol-names.js | 1 + ...s-same-line-method-static-literal-names.js | 1 + ...s-same-line-method-static-private-names.js | 65 +++++++++++ ...s-same-line-method-string-literal-names.js | 1 + .../fields-wrapped-in-sc-computed-names.js | 1 + ...lds-wrapped-in-sc-computed-symbol-names.js | 1 + .../fields-wrapped-in-sc-literal-names.js | 1 + .../fields-wrapped-in-sc-private-names.js | 57 ++++++++++ ...lds-wrapped-in-sc-static-computed-names.js | 1 + ...pped-in-sc-static-computed-symbol-names.js | 1 + ...elds-wrapped-in-sc-static-literal-names.js | 1 + ...elds-wrapped-in-sc-static-private-names.js | 57 ++++++++++ ...elds-wrapped-in-sc-string-literal-names.js | 1 + 306 files changed, 4854 insertions(+) create mode 100644 test/language/expressions/class/fields-after-same-line-gen-private-names.js create mode 100644 test/language/expressions/class/fields-after-same-line-gen-static-private-names.js create mode 100644 test/language/expressions/class/fields-after-same-line-method-private-names.js create mode 100644 test/language/expressions/class/fields-after-same-line-method-static-private-names.js create mode 100644 test/language/expressions/class/fields-after-same-line-static-async-gen-private-names.js create mode 100644 test/language/expressions/class/fields-after-same-line-static-async-gen-static-private-names.js create mode 100644 test/language/expressions/class/fields-after-same-line-static-async-method-private-names.js create mode 100644 test/language/expressions/class/fields-after-same-line-static-async-method-static-private-names.js create mode 100644 test/language/expressions/class/fields-after-same-line-static-gen-private-names.js create mode 100644 test/language/expressions/class/fields-after-same-line-static-gen-static-private-names.js create mode 100644 test/language/expressions/class/fields-after-same-line-static-method-private-names.js create mode 100644 test/language/expressions/class/fields-after-same-line-static-method-static-private-names.js create mode 100644 test/language/expressions/class/fields-multiple-definitions-private-names.js create mode 100644 test/language/expressions/class/fields-multiple-definitions-static-private-names.js create mode 100644 test/language/expressions/class/fields-multiple-stacked-definitions-private-names.js create mode 100644 test/language/expressions/class/fields-multiple-stacked-definitions-static-private-names.js create mode 100644 test/language/expressions/class/fields-new-no-sc-line-method-private-names.js create mode 100644 test/language/expressions/class/fields-new-no-sc-line-method-static-private-names.js create mode 100644 test/language/expressions/class/fields-new-sc-line-gen-private-names.js create mode 100644 test/language/expressions/class/fields-new-sc-line-gen-static-private-names.js create mode 100644 test/language/expressions/class/fields-new-sc-line-method-private-names.js create mode 100644 test/language/expressions/class/fields-new-sc-line-method-static-private-names.js create mode 100644 test/language/expressions/class/fields-regular-definitions-private-names.js create mode 100644 test/language/expressions/class/fields-regular-definitions-static-private-names.js create mode 100644 test/language/expressions/class/fields-same-line-async-gen-private-names.js create mode 100644 test/language/expressions/class/fields-same-line-async-gen-static-private-names.js create mode 100644 test/language/expressions/class/fields-same-line-async-method-private-names.js create mode 100644 test/language/expressions/class/fields-same-line-async-method-static-private-names.js create mode 100644 test/language/expressions/class/fields-same-line-gen-private-names.js create mode 100644 test/language/expressions/class/fields-same-line-gen-static-private-names.js create mode 100644 test/language/expressions/class/fields-same-line-method-private-names.js create mode 100644 test/language/expressions/class/fields-same-line-method-static-private-names.js create mode 100644 test/language/expressions/class/fields-wrapped-in-sc-private-names.js create mode 100644 test/language/expressions/class/fields-wrapped-in-sc-static-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-gen-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-gen-static-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-method-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-method-static-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-static-async-gen-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-static-async-gen-static-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-static-async-method-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-static-async-method-static-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-static-gen-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-static-gen-static-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-static-method-private-names.js create mode 100644 test/language/statements/class/fields-after-same-line-static-method-static-private-names.js create mode 100644 test/language/statements/class/fields-multiple-definitions-private-names.js create mode 100644 test/language/statements/class/fields-multiple-definitions-static-private-names.js create mode 100644 test/language/statements/class/fields-multiple-stacked-definitions-private-names.js create mode 100644 test/language/statements/class/fields-multiple-stacked-definitions-static-private-names.js create mode 100644 test/language/statements/class/fields-new-no-sc-line-method-private-names.js create mode 100644 test/language/statements/class/fields-new-no-sc-line-method-static-private-names.js create mode 100644 test/language/statements/class/fields-new-sc-line-gen-private-names.js create mode 100644 test/language/statements/class/fields-new-sc-line-gen-static-private-names.js create mode 100644 test/language/statements/class/fields-new-sc-line-method-private-names.js create mode 100644 test/language/statements/class/fields-new-sc-line-method-static-private-names.js create mode 100644 test/language/statements/class/fields-regular-definitions-private-names.js create mode 100644 test/language/statements/class/fields-regular-definitions-static-private-names.js create mode 100644 test/language/statements/class/fields-same-line-async-gen-private-names.js create mode 100644 test/language/statements/class/fields-same-line-async-gen-static-private-names.js create mode 100644 test/language/statements/class/fields-same-line-async-method-private-names.js create mode 100644 test/language/statements/class/fields-same-line-async-method-static-private-names.js create mode 100644 test/language/statements/class/fields-same-line-gen-private-names.js create mode 100644 test/language/statements/class/fields-same-line-gen-static-private-names.js create mode 100644 test/language/statements/class/fields-same-line-method-private-names.js create mode 100644 test/language/statements/class/fields-same-line-method-static-private-names.js create mode 100644 test/language/statements/class/fields-wrapped-in-sc-private-names.js create mode 100644 test/language/statements/class/fields-wrapped-in-sc-static-private-names.js 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 689a4f8167..4b69ab918d 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 0b66155c2d..04b88ace7b 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 594773b596..31bfb64751 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 0000000000..ffaa9a3ce7 --- /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 84f29734cc..950cde0b7d 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 dff0f916d5..862006eb8c 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 82ad2348d3..8c142d28dc 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 0000000000..4c34ca6a24 --- /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 702d11f6c7..83f0e3000c 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 9ea365d415..315dbf91fc 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 78cf52e389..59fcfd8a8c 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 86eb9b5794..a41dd10ec5 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 0000000000..36f3fb297e --- /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 b28a11e2ee..a7b45b5fd5 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 bfe62d6b9e..9bc01fb70b 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 4767ff8947..53a5733491 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 0000000000..3a382f7304 --- /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 4f393da149..4299b5e823 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 bf8a4bdeb9..19c7a83737 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 6bb1f56089..83fd381d86 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 1fb3501f8d..140c82b712 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 0000000000..24af08bea3 --- /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 ad0b5b741c..f82df5a61e 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 8946ee477b..c2ee765339 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 62524d9b0f..5abb238d56 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 0000000000..70a7fbfe0a --- /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 bb42ef8fca..6a8912fd79 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 5f1fff697d..e752e8b78b 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 071c3e4e1a..3c84401887 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 f2a3391cfc..e3c2aa56d9 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 0000000000..fc503358f1 --- /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 a89010e654..22f43ebd34 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 4a0983ac61..6f560a3b11 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 c02d0b1f9c..698af044bd 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 0000000000..9f003c5a79 --- /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 1503ccc530..91b742b2ff 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 e2cdc91e97..d5998b97b4 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 82b909edb3..61d79d1619 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 81084ac8eb..2211245759 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 0000000000..cda34230e4 --- /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 7995c9c4d0..afc6684050 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 ddfe132f17..352e674277 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 184d8ad792..f399ad676c 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 0000000000..3737195c3e --- /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 871c99f054..9e97ccb68a 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 a941be27e5..63a43adc81 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 1eebc6280a..7c55fa7561 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 2019767e1e..2dde2d09c1 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 0000000000..2e8fecf222 --- /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 d4606dca5b..b307989ef2 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 b24c07b5a6..cc85063ea9 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 145ebc858b..0dc301af6e 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 0000000000..35ff7f11f5 --- /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 912d3fd842..9478ba2014 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 416ad8c13b..610be4d561 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 8519a7ca22..fe316fa767 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 363a59ef61..efe198d20a 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 0000000000..24c1a7f4d3 --- /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 8cad37f657..2666dbfbbf 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 532e33e6fe..fad1bd2be6 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 41582a4765..2a99b9ceeb 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 0000000000..c501bd1184 --- /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 01d14e5548..a13a44c26c 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 5edb040779..3271e38e3c 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 ebfb312d38..e9d610605c 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 b03279776e..71f21a5f88 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 0000000000..543a968bbb --- /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 d41fc55b61..b33aabe334 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 c4ae11ed6f..ed8e6280b3 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 36dd4190a0..2c2bcfb46d 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 0000000000..668588fdb1 --- /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 9b21d9a004..32edf331d7 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 7b378eb56a..50354308aa 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 e986e9a250..da7b129ba0 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 33007a0f15..6b927da89e 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 0000000000..e9dfb809d0 --- /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 8a3b917eac..09d71d21f2 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 661596f15d..c4f818aad1 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 ff5e5d6ecd..7c6b809956 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 0000000000..2417c0e000 --- /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 bb0f8ad79b..e79b91f747 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 90ce595755..060487bd3c 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 53ea165611..1ea70aa907 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 d72b29e1c1..8398577332 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 0000000000..2a3a38aafa --- /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 43aa375b2a..26e4996cdd 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 38e0979436..dadfa266a5 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 25263cd726..1af95389af 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 0000000000..d3d6df8466 --- /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 a9054101c2..ac1db02e5e 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 afb17620df..0c3f140903 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 a8c0c3fffe..c79e78b692 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 3d533ee809..65211827da 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 0000000000..ec5a05514c --- /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 bf2ebf7bca..bd75e09307 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 195d9ff007..13884286ad 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 0b5766c6d3..bd1f8e580f 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 0000000000..db772d9cb5 --- /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 e48c11bbd0..4848372bc7 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 2cc6d56d4c..746b198020 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 f01646bcd4..f9b39e52f5 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 16f2cd297d..e88342eee2 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 0000000000..820c580a80 --- /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 561a7b7f50..8879a1750c 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 8b4cc347f3..29eb4ddfac 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 c7219210e1..fc69466a9f 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 0000000000..7d2f657dd0 --- /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 6636aa21ab..e3c88c0dfd 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 0755918d0f..f408cfc76e 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 a02b46b4e5..ef71fb51ed 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 c3dc382d5c..2d319f7076 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 0000000000..91f10dea08 --- /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 0f0fe55d58..cdcef449d9 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 6b88f56e46..05a1577c21 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 84ebcbff9c..62152bfb5e 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 0000000000..f4103058a0 --- /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 6201b2ee9f..e234e6a251 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 1cfdda5720..f0c94430fc 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 c350934b08..cd350573ef 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 efe14403cf..43fe91047f 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 0000000000..2953e2086d --- /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 481ba48e0f..dfbf3851f6 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 7d8db59d26..6582fc2633 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 da30532722..7939ee1017 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 0000000000..e9eaff6fef --- /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 30ed0aac6b..af5eddbfb5 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 2b0fba7c56..c67abb3104 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 f6ea225438..e9384c0be5 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 39da637603..df9d20e47b 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 0000000000..db78242bcd --- /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 cb38eb406c..9b0cc9600e 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 46ca7a8c17..a01a5ede38 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 dc13ee4b80..91736e5779 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 0000000000..21db44d20c --- /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 8f6e5c4b71..aecc8d8300 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 8faaddf426..198e9c7665 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 3a3bd34f80..546335b131 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 ee77250026..cb60f45d6d 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 0000000000..7bbab8a370 --- /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 8e3cd8f51f..5930c06f30 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 09083ff8af..dd393a37da 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 0f579bca90..2777dc90ca 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 0000000000..64fd72a2ef --- /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 3f39a6c021..1f55af229b 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 51fdf456a6..2178a39831 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 b678529926..7745a0ebe3 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 7a5080a738..9b6701e6d4 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 0000000000..7ddf759a57 --- /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 34025f9b2e..5a15b36a27 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 b8fb78a25a..77aec775d4 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 89167a3746..f9f5bee3cb 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 0000000000..e057d93989 --- /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 da2af62bb4..b053d3f2c0 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 c065aa9ce2..2e69fe1de4 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 b660d1516f..532c5fb81a 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 aefe0864e2..64b5878a42 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 0000000000..4dc789e3ba --- /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 28592739c2..1714b3e19f 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 1f77fc4342..8e737374a3 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 d88e134754..3eb013c219 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 0000000000..72a274976d --- /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 a3fe6c62de..f03c5b2625 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 6933e4b941..b8cce540f3 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 129f49c98d..2c228a4c1f 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 a0facfffdb..5217248204 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 0000000000..f399c371c3 --- /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 7c454d2ba9..131e855153 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 d529c257ed..0abf67a8f9 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 5f63b572fd..1d175ffa47 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 0000000000..0c18445e06 --- /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 c6222fa49f..ec1ead9be5 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 41e3e93104..5662b1106f 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 468e2b35d5..43a25adcb9 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 5ce9a6054d..06142a248c 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 0000000000..19c10607e8 --- /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 09427e35e2..966e0817b0 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 7b90798bb3..bd93cf5b57 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 e72e69a3f3..8aeaec51ac 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 0000000000..02fef68692 --- /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 7b698a4528..e20ea1e276 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 44fa754faa..18cd384ed0 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 ebc558f7ee..ba746b259a 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 daa3eb6f39..f6491d50e0 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 0000000000..bfe3cb9923 --- /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 074733ef00..1903ccd193 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 dccfeccbca..82b80339c0 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 797d3f3449..9ee0a2d901 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 0000000000..9b59318c79 --- /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 e78203eb90..25d5739783 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 5cccb361c5..3d3630e5b0 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 10a206d172..c4a3ab1b52 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 7fda7a16ad..6cf085ffe3 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 0000000000..8a2a3af3c2 --- /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 f82bd491db..6f56849771 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 6a16e2c9f9..7c145d15f0 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 27c082886e..b0941f3426 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 0000000000..c8feba6c93 --- /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 88ecc88985..ea9fbf7c29 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 53b8e3bb5d..fc7b80248f 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 bab33bb165..f20707ab32 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 8cf005134e..32dffcf65e 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 0000000000..45f5e7ae74 --- /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 4b196c0a41..09196da792 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 153d0320b3..4f1f908b91 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 43341468bd..92978d97c5 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 0000000000..5062d1a9ba --- /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 0e4a59e6af..7d9ff3f5cf 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 8c15af84f4..4294f2c25e 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 28f0a8845b..b7be8668b9 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 de483bfa22..9dc40ee6e0 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 0000000000..b33dd70546 --- /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 09293f69f0..944e702051 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 b0d336fdfd..c3b178ad60 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 672f36cd14..8d3da71b39 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 0000000000..fe883fde24 --- /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 0bdc197481..c8942f783b 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 e84d859b83..bc6141881d 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 a829009a15..d25cd00868 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 8992888f6a..e2c3689cb9 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 0000000000..e9b855f9eb --- /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 7cf2fe2717..b87ec755f9 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 d41baa279f..4d82de70d5 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 906c3f943b..a9b1304004 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 0000000000..b0bcd84f79 --- /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 fb77541047..84d3f59529 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 013601d880..239282f2b3 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 b35333bea1..9b9590ba8e 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 0f81ff3861..e5cdf9402b 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 0000000000..faea882b9e --- /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 d6e4ea3793..79f6a88fef 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 ef9cd465e7..a90c7a4455 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 8bd683b9c1..98f7c9aa88 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 0000000000..4317c7914a --- /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 f653063e9e..99d49b49cb 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 25d735e9f6..493a327787 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 771e1f1761..83ec80c1d2 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 9a645cb45d..724fdf9bfe 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 0000000000..dd4e4e4edb --- /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 fd4c046dfe..28d063451e 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 d965b31d0a..e4bf73ea61 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 58b5cbb20c..d29d2e04e0 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 0000000000..f624f26259 --- /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 79a7607ab6..8e6ba68c54 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 d7403fd735..f7fe3f3365 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 bb1a24b314..51d944e0bd 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 7d23f42bb3..1b48da7ba0 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 0000000000..cdc9649b62 --- /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 26c6d4e194..4dc70efe93 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 91b260883f..9bcf7aaa0f 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 f86f7da7ab..577d066624 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 0000000000..89cf71314b --- /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 713991137e..bcf19587a6 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 331ef29084..0e85698b39 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 8ad7d54095..683a6ccef3 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 f4710fd7bd..0782d14a99 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 0000000000..7e4651ab3c --- /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 bad49f1af3..ae920aa497 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 a713299d5f..c385f74158 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 d032244bb4..0a5bd05aac 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 0000000000..7ba1403474 --- /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 f56f41323b..1a445b4a73 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 0f7c38f1b3..ac8cacad70 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 a228b84037..9852dfbc48 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 166b2d15b0..ec2409554d 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 0000000000..81f89c9401 --- /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 f324abb96f..bfb5649172 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 f674c4e163..b4ef5d8038 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 4bca5f27a4..cffbe5f17a 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 0000000000..a77dcc91c0 --- /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 7c01efaea3..2c243305c4 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 68e037e005..f0c5c73381 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 4f02dbe52d..efec870e33 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 67536a51a3..7c0ceceef3 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 0000000000..e21a55ef96 --- /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 0b472e348c..10e9395f7f 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 230544aa56..972b4d1ada 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 cecaa9bf0a..222b543ea3 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 0000000000..1a979fe4f3 --- /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 c3415ec925..41a045c951 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 7ce2a5a0c7..1cd7bf8ac5 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 ac8092d5bf..976730d9ec 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 689e9cb256..38ee4803e4 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 0000000000..c9932a5d27 --- /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 6544e21aee..4d5bb30a57 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 ec324d8356..49c4af92ec 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 0a624e21c2..13c4a74778 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 0000000000..efd7f51e4a --- /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 5eb4b49120..b5fedce627 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 a94d95379a..19b7c975c8 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 e8ca9aa779..97a65e7392 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 35f339943e..1a21e559ba 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 0000000000..5103c757c8 --- /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 7e0cf4ba85..cf05838969 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 1f8cb7ae89..5178507b42 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 adee793e19..c31274b022 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 0000000000..0e46dc5e76 --- /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 1c7b66528e..a80773cc03 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 a4729fb8ab..c550ee442e 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 fc793e10cb..b1479ba393 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 103b0e06e7..44a9e1dbeb 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 0000000000..9ee3926476 --- /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 96434be4c2..4a315dec74 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 3539cf1626..e86fb600cc 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 ef8a81c6ff..71170aa351 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 0000000000..046949b3ac --- /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 51a4863a69..84d6729682 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();