mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 22:15:24 +02:00
Merge pull request #1699 from jbhoosreddy/private-generator-method
test: Add private generator method tests (#1343)
This commit is contained in:
commit
30c2355329
@ -20,12 +20,16 @@ BigInt
|
|||||||
class-fields-public
|
class-fields-public
|
||||||
class-fields-private
|
class-fields-private
|
||||||
|
|
||||||
# Static Class Fields & Methods:
|
# Static Class Fields & Methods:
|
||||||
# https://github.com/tc39/proposal-static-class-features/
|
# https://github.com/tc39/proposal-static-class-features/
|
||||||
class-static-fields-public
|
class-static-fields-public
|
||||||
class-static-fields-private
|
class-static-fields-private
|
||||||
class-static-methods-private
|
class-static-methods-private
|
||||||
|
|
||||||
|
# Private methods and getter/setters
|
||||||
|
# https://github.com/tc39/proposal-private-methods
|
||||||
|
class-methods-private
|
||||||
|
|
||||||
# Promise.prototype.finally
|
# Promise.prototype.finally
|
||||||
# https://github.com/tc39/proposal-promise-finally
|
# https://github.com/tc39/proposal-promise-finally
|
||||||
Promise.prototype.finally
|
Promise.prototype.finally
|
||||||
|
@ -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 }*/
|
||||||
|
}}
|
@ -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 }*/
|
||||||
|
}}
|
@ -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 }*/
|
||||||
|
}};
|
@ -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 }*/
|
||||||
|
}};
|
@ -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")');
|
@ -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")');
|
@ -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")');
|
@ -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")');
|
@ -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 }*/
|
||||||
|
}}
|
@ -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 }*/
|
||||||
|
}}
|
@ -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 }*/
|
||||||
|
}};
|
@ -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 }*/
|
||||||
|
}};
|
@ -2,7 +2,7 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
/*---
|
/*---
|
||||||
path: language/statements/class/gen-method-
|
path: language/statements/class/gen-method-
|
||||||
name: Geenerator method as a ClassDeclaration element
|
name: Generator method as a ClassDeclaration element
|
||||||
esid: prod-GeneratorMethod
|
esid: prod-GeneratorMethod
|
||||||
info: |
|
info: |
|
||||||
ClassElement :
|
ClassElement :
|
||||||
|
47
src/generators/default/class-decl-private-method.template
Normal file
47
src/generators/default/class-decl-private-method.template
Normal file
@ -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")');
|
@ -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")');
|
47
src/generators/default/class-expr-private-method.template
Normal file
47
src/generators/default/class-expr-private-method.template
Normal file
@ -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")');
|
@ -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")');
|
23
src/generators/syntax/class-decl-private-method.template
Normal file
23
src/generators/syntax/class-decl-private-method.template
Normal file
@ -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 }*/
|
||||||
|
}}
|
@ -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 }*/
|
||||||
|
}}
|
23
src/generators/syntax/class-expr-private-method.template
Normal file
23
src/generators/syntax/class-expr-private-method.template
Normal file
@ -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 }*/
|
||||||
|
}};
|
@ -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 }*/
|
||||||
|
}};
|
Loading…
x
Reference in New Issue
Block a user