diff --git a/features.txt b/features.txt index 36ef5360ff65114327e68e47b5f28510214fdb1b..1cf8f2ac43de5f5db1ae3557cd1e775415f04bc5 100644 --- a/features.txt +++ b/features.txt @@ -20,12 +20,16 @@ BigInt class-fields-public class-fields-private -# Static Class Fields & Methods: +# Static Class Fields & Methods: # https://github.com/tc39/proposal-static-class-features/ class-static-fields-public class-static-fields-private class-static-methods-private +# Private methods and getter/setters +# https://github.com/tc39/proposal-private-methods +class-methods-private + # Promise.prototype.finally # https://github.com/tc39/proposal-promise-finally Promise.prototype.finally diff --git a/src/async-functions/syntax/async-class-decl-private-method.template b/src/async-functions/syntax/async-class-decl-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..5a3949ab247138bd950c3957d5c3cca16f3e2bec --- /dev/null +++ b/src/async-functions/syntax/async-class-decl-private-method.template @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-private-method- +name: Async private method as a ClassDeclaration element +esid: prod-AsyncMethod +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } +features: [async-functions, class-methods-private] +---*/ + +class C { async #method() { + /*{ body }*/ +}} diff --git a/src/async-functions/syntax/async-class-decl-static-private-method.template b/src/async-functions/syntax/async-class-decl-static-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..0bede5a4590a0b16cb1a81ff51d1071fced7e1cf --- /dev/null +++ b/src/async-functions/syntax/async-class-decl-static-private-method.template @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-private-method-static- +name: Static async private method as a ClassDeclaration element +esid: prod-AsyncMethod +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } +features: [async-functions, class-methods-private] +---*/ + +class C { static async #method() { + /*{ body }*/ +}} diff --git a/src/async-functions/syntax/async-class-expr-private-method.template b/src/async-functions/syntax/async-class-expr-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..8f047f74d02a26f77f7d592d04088f0b7f8dfff1 --- /dev/null +++ b/src/async-functions/syntax/async-class-expr-private-method.template @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/async-private-method- +name: Async private method as a ClassExpression element +esid: prod-AsyncMethod +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } +features: [async-functions, class-methods-private] +---*/ + +var C = class { async #method() { + /*{ body }*/ +}}; diff --git a/src/async-functions/syntax/async-class-expr-static-private-method.template b/src/async-functions/syntax/async-class-expr-static-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..ab154f12f57e9b6de4e3dc5a2aaef1eed477095e --- /dev/null +++ b/src/async-functions/syntax/async-class-expr-static-private-method.template @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/async-private-method-static- +name: Static private async method as a ClassExpression element +esid: prod-AsyncMethod +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncMethod + + Async Function Definitions + + AsyncMethod : + async [no LineTerminator here] # PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } +features: [async-functions, class-methods-private] +---*/ + +var C = class { static async #method() { + /*{ body }*/ +}}; diff --git a/src/async-generators/default/async-class-decl-private-method.template b/src/async-generators/default/async-class-decl-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..44ff11ea49d826dcb822c1fbacd0ee178568fdde --- /dev/null +++ b/src/async-generators/default/async-class-decl-private-method.template @@ -0,0 +1,48 @@ +// Copyright (C) 2018 Bloomberb LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-gen-private-method- +name: Async Generator method as a ClassDeclaration element +esid: prod-AsyncGeneratorPrivateMethod +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +features: [async-iteration, class-methods-private] +---*/ + +var callCount = 0; + +class C { + async *#gen() { + callCount += 1; + /*{ body }*/ + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +/*{ assertions }*/ + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/src/async-generators/default/async-class-decl-static-private-method.template b/src/async-generators/default/async-class-decl-static-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..9e4f7d5fc13602541ee0bcf48a3ed16becb2737b --- /dev/null +++ b/src/async-generators/default/async-class-decl-static-private-method.template @@ -0,0 +1,44 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-gen-private-method-static- +name: Static async generator method as a ClassDeclaration element +esid: prod-AsyncGeneratorPrivateMethod +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +features: [async-iteration, class-static-methods-private] +---*/ + +var callCount = 0; + +class C { + static async *#gen() { + callCount += 1; + /*{ body }*/ + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +/*{ assertions }*/ + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/src/async-generators/default/async-class-expr-private-method.template b/src/async-generators/default/async-class-expr-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..c2509020a520ae967bac70febde95116fbc3e799 --- /dev/null +++ b/src/async-generators/default/async-class-expr-private-method.template @@ -0,0 +1,48 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/async-gen-private-method- +name: Async generator method as a ClassExpression element +esid: prod-AsyncGeneratorPrivateMethod +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +features: [async-iteration, class-methods-private] +---*/ + +var callCount = 0; + +var C = class { + async *#gen() { + callCount += 1; + /*{ body }*/ + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +/*{ assertions }*/ + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/src/async-generators/default/async-class-expr-static-private-method.template b/src/async-generators/default/async-class-expr-static-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..828930de22d3e4f7c403210f68ffaff4ef9d3c37 --- /dev/null +++ b/src/async-generators/default/async-class-expr-static-private-method.template @@ -0,0 +1,44 @@ +// Copyright (C) 2018 Bloomberg L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/async-gen-private-method-static- +name: Static async generator method as a ClassExpression element +esid: prod-AsyncGeneratorPrivateMethod +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +features: [async-iteration, class-static-methods-private] +---*/ + +var callCount = 0; + +var C = class { + static async *#gen() { + callCount += 1; + /*{ body }*/ + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +/*{ assertions }*/ + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/src/async-generators/syntax/async-class-decl-private-method.template b/src/async-generators/syntax/async-class-decl-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..b9072ff2d5dababd1b1c715ad8d6e51233f185e1 --- /dev/null +++ b/src/async-generators/syntax/async-class-decl-private-method.template @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-gen-private-method- +name: Async Generator private method as a ClassDeclaration element +esid: prod-AsyncGeneratorMethod +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +features: [async-iteration, class-methods-private] +---*/ + +class C { async *#gen() { + /*{ body }*/ +}} diff --git a/src/async-generators/syntax/async-class-decl-static-private-method.template b/src/async-generators/syntax/async-class-decl-static-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..afa110b27cd9857564702665c17ce9e03b421d82 --- /dev/null +++ b/src/async-generators/syntax/async-class-decl-static-private-method.template @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-gen-private-method-static- +name: Static async generator private method as a ClassDeclaration element +esid: prod-AsyncGeneratorMethod +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +features: [async-iteration, class-methods-private] +---*/ + +class C { static async *#gen() { + /*{ body }*/ +}} diff --git a/src/async-generators/syntax/async-class-expr-private-method.template b/src/async-generators/syntax/async-class-expr-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..78938bc4a045c8442b27936ab6671efd112ed300 --- /dev/null +++ b/src/async-generators/syntax/async-class-expr-private-method.template @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/async-gen-private-method- +name: Async generator private method as a ClassExpression element +esid: prod-AsyncGeneratorMethod +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +features: [async-iteration, class-methods-private] +---*/ + +var C = class { async *#gen() { + /*{ body }*/ +}}; diff --git a/src/async-generators/syntax/async-class-expr-static-private-method.template b/src/async-generators/syntax/async-class-expr-static-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..c69608ebf41c8d479104874a8a8410d3bad99a24 --- /dev/null +++ b/src/async-generators/syntax/async-class-expr-static-private-method.template @@ -0,0 +1,24 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/async-gen-private-method-static- +name: Static async generator private method as a ClassExpression element +esid: prod-AsyncGeneratorMethod +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + AsyncGeneratorMethod + + Async Generator Function Definitions + + AsyncGeneratorMethod : + async [no LineTerminator here] * # PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody } +features: [async-iteration, class-methods-private] +---*/ + +var C = class { static async *#gen() { + /*{ body }*/ +}}; diff --git a/src/generators/default/class-decl-method.template b/src/generators/default/class-decl-method.template index 334145980a0d55dcd3a11f866520bf5db174aa0a..a1562a76fa447fc810caacf2b0ed1006021bf483 100644 --- a/src/generators/default/class-decl-method.template +++ b/src/generators/default/class-decl-method.template @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- path: language/statements/class/gen-method- -name: Geenerator method as a ClassDeclaration element +name: Generator method as a ClassDeclaration element esid: prod-GeneratorMethod info: | ClassElement : diff --git a/src/generators/default/class-decl-private-method.template b/src/generators/default/class-decl-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..3d5c4f69160a991221dbb8b030c2f5aa5cc1981c --- /dev/null +++ b/src/generators/default/class-decl-private-method.template @@ -0,0 +1,47 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/gen-method- +name: Generator private method as a ClassDeclaration element +esid: prod-GeneratorPrivateMethod +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } +features: [generators, class-methods-private] +---*/ + +var callCount = 0; + +class C { + *#gen() { + callCount += 1; + /*{ body }*/ + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +/*{ assertions }*/ + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/src/generators/default/class-decl-static-private-method.template b/src/generators/default/class-decl-static-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..4a5f38b801cbff6208db0d43f73511335941233d --- /dev/null +++ b/src/generators/default/class-decl-static-private-method.template @@ -0,0 +1,43 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/gen-private-method-static- +name: Static generator private method as a ClassDeclaration element +esid: prod-GeneratorPrivateMethod +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } +features: [generators, class-static-methods-private] +---*/ + +var callCount = 0; + +class C { + static *#gen() { + callCount += 1; + /*{ body }*/ + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +/*{ assertions }*/ + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/src/generators/default/class-expr-private-method.template b/src/generators/default/class-expr-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..cede4ddfb0aebb742dbab9095b8aa97da99bb3f9 --- /dev/null +++ b/src/generators/default/class-expr-private-method.template @@ -0,0 +1,47 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/gen-private-method- +name: Generator private method as a ClassExpression element +esid: prod-GeneratorPrivateMethod +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } +features: [generators, class-methods-private] +---*/ + +var callCount = 0; + +var C = class { + *#gen() { + callCount += 1; + /*{ body }*/ + } + get gen() { return this.#gen; } +} + +const c = new C(); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); + +var iter = c.gen(); + +/*{ assertions }*/ + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties after set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(c, "#gen"), false, 'Object.hasOwnProperty.call(c, "#gen")'); diff --git a/src/generators/default/class-expr-static-private-method.template b/src/generators/default/class-expr-static-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..eb150dfcafe13bb7a9216f40035a5a331dda6458 --- /dev/null +++ b/src/generators/default/class-expr-static-private-method.template @@ -0,0 +1,43 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/gen-private-method-static- +name: Static generator private method as a ClassExpression element +esid: prod-GeneratorPrivateMethod +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * PropertyName ( UniqueFormalParameters ) { GeneratorBody } +features: [generators, class-static-methods-private] +---*/ + +var callCount = 0; + +var C = class { + static *#gen() { + callCount += 1; + /*{ body }*/ + } + static get gen() { return this.#gen; } +} + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); + +var iter = C.gen(); + +/*{ assertions }*/ + +assert.sameValue(callCount, 1); + +// Test the private fields do not appear as properties before set to value +assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#gen"), false, 'Object.hasOwnProperty.call(C.prototype, "#gen")'); +assert.sameValue(Object.hasOwnProperty.call(C, "#gen"), false, 'Object.hasOwnProperty.call(C, "#gen")'); diff --git a/src/generators/syntax/class-decl-private-method.template b/src/generators/syntax/class-decl-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..52877753eef1207401388d2da938e377d28d2116 --- /dev/null +++ b/src/generators/syntax/class-decl-private-method.template @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/gen-private-method- +name: Generator method as a ClassDeclaration element +esid: prod-GeneratorMethod +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } +features: [generators, class-methods-private] +---*/ + +class C { *#gen() { + /*{ body }*/ +}} diff --git a/src/generators/syntax/class-decl-static-private-method.template b/src/generators/syntax/class-decl-static-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..cf55b4d5ac8e4ebe1a51477da98149d12fb3cea4 --- /dev/null +++ b/src/generators/syntax/class-decl-static-private-method.template @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/gen-private-method-static- +name: Static generator method as a ClassDeclaration element +esid: prod-GeneratorMethod +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } +features: [generators, class-methods-private] +---*/ + +class C {static *#gen() { + /*{ body }*/ +}} diff --git a/src/generators/syntax/class-expr-private-method.template b/src/generators/syntax/class-expr-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..db8559834c55306adc65bec28e4e725999a2fa62 --- /dev/null +++ b/src/generators/syntax/class-expr-private-method.template @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/gen-private-method- +name: Generator private method as a ClassExpression element +esid: prod-GeneratorMethod +info: | + ClassElement : + PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } +features: [generators, class-methods-private] +---*/ + +var C = class {*#gen() { + /*{ body }*/ +}}; diff --git a/src/generators/syntax/class-expr-static-private-method.template b/src/generators/syntax/class-expr-static-private-method.template new file mode 100644 index 0000000000000000000000000000000000000000..b66123d79db4a684e656b8e32ce35ef5f9266582 --- /dev/null +++ b/src/generators/syntax/class-expr-static-private-method.template @@ -0,0 +1,23 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/gen-private-method-static- +name: Static generator private method as a ClassExpression element +esid: prod-GeneratorMethod +info: | + ClassElement : + static PrivateMethodDefinition + + MethodDefinition : + GeneratorMethod + + 14.4 Generator Function Definitions + + GeneratorMethod : + * # PropertyName ( UniqueFormalParameters ) { GeneratorBody } +features: [generators, class-methods-private] +---*/ + +var C = class { static *#gen() { + /*{ body }*/ +}};