mirror of https://github.com/tc39/test262.git
Merge pull request #2322 from caiolima/private-method-length
Added private method length cases
This commit is contained in:
commit
0e30ee06c9
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Anonymous function in field initilizer have length properly set
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
FieldDefinition :
|
||||||
|
ClassElementName Initializer_opt
|
||||||
|
|
||||||
|
InitializeInstanceFields ( O, constructor )
|
||||||
|
1. Assert: Type ( O ) is Object.
|
||||||
|
2. Assert: constructor is an ECMAScript function object.
|
||||||
|
3. Let fields be the value of constructor.[[Fields]].
|
||||||
|
4. For each item fieldRecord in order from fields,
|
||||||
|
a. Perform ? DefineField(O, fieldRecord).
|
||||||
|
5. Return.
|
||||||
|
|
||||||
|
DefineField(receiver, fieldRecord)
|
||||||
|
1. Assert: Type(receiver) is Object.
|
||||||
|
2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation.
|
||||||
|
3. Let name be fieldRecord.[[Name]].
|
||||||
|
4. Let initializer be fieldRecord.[[Initializer]].
|
||||||
|
5. If initializer is not empty, then
|
||||||
|
a. Let initValue be ? Call(initializer, receiver).
|
||||||
|
...
|
||||||
|
template: default
|
||||||
|
features: [class-static-fields-private, class-static-fields-public]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- elements
|
||||||
|
field = function() {};
|
||||||
|
#field = (a, b, c, d) => undefined;
|
||||||
|
|
||||||
|
accessPrivateField() {
|
||||||
|
return this.#field;
|
||||||
|
}
|
||||||
|
//- assertions
|
||||||
|
let c = new C();
|
||||||
|
assert.sameValue(c.accessPrivateField().length, 4);
|
||||||
|
assert.sameValue(c.field.length, 0);
|
|
@ -0,0 +1,43 @@
|
||||||
|
// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private methods have length property properly configured
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype".
|
||||||
|
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static".
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject.
|
||||||
|
2. ReturnIfAbrupt(methodDef).
|
||||||
|
3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable).
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable.
|
||||||
|
2. Return empty.
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName (UniqueFormalParameters) { FunctionBody }
|
||||||
|
...
|
||||||
|
8. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, privateScope, strict, prototype).
|
||||||
|
9. Perform MakeMethod(closure, object).
|
||||||
|
10. Return the Record{[[Key]]: propKey, [[Closure]]: closure}.
|
||||||
|
template: default
|
||||||
|
features: [class-methods-private]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- elements
|
||||||
|
#method(a) {};
|
||||||
|
|
||||||
|
getPrivateMethod() {
|
||||||
|
return this.#method;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- assertions
|
||||||
|
let c = new C();
|
||||||
|
assert.sameValue(c.getPrivateMethod().length, 1);
|
|
@ -0,0 +1,42 @@
|
||||||
|
// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private static methods have length property properly configured
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype".
|
||||||
|
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static".
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject.
|
||||||
|
2. ReturnIfAbrupt(methodDef).
|
||||||
|
3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable).
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable.
|
||||||
|
2. Return empty.
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName (UniqueFormalParameters) { FunctionBody }
|
||||||
|
...
|
||||||
|
8. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, privateScope, strict, prototype).
|
||||||
|
9. Perform MakeMethod(closure, object).
|
||||||
|
10. Return the Record{[[Key]]: propKey, [[Closure]]: closure}.
|
||||||
|
template: default
|
||||||
|
features: [class-static-methods-private]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- elements
|
||||||
|
static #method(a, b, c) {};
|
||||||
|
|
||||||
|
static getPrivateMethod() {
|
||||||
|
return this.#method;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- assertions
|
||||||
|
assert.sameValue(C.getPrivateMethod().length, 3);
|
|
@ -0,0 +1,57 @@
|
||||||
|
// Copyright (C) 2019 Caio Lima (Igalia SL). All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Anonymous function in field initilizer have length properly set
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
ClassElement :
|
||||||
|
...
|
||||||
|
static FieldDefinition ;
|
||||||
|
|
||||||
|
FieldDefinition :
|
||||||
|
ClassElementName Initializer_opt
|
||||||
|
|
||||||
|
ClassDefinitionEvaluation:
|
||||||
|
...
|
||||||
|
|
||||||
|
27. Let staticFields be a new empty List.
|
||||||
|
28. For each ClassElement e in order from elements,
|
||||||
|
a. If IsStatic of e is false, then
|
||||||
|
...
|
||||||
|
b. Else,
|
||||||
|
i. Let field be the result of performing PropertyDefinitionEvaluation for m ClassElementEvaluation for e with arguments F and false.
|
||||||
|
c. If field is an abrupt completion, then
|
||||||
|
...
|
||||||
|
d. If field is not empty,
|
||||||
|
i. If IsStatic of e is false, append field to instanceFields.
|
||||||
|
ii. Otherwise, append field to staticFields.
|
||||||
|
|
||||||
|
34. For each item fieldRecord in order from staticFields,
|
||||||
|
a. Perform ? DefineField(F, field).
|
||||||
|
...
|
||||||
|
|
||||||
|
DefineField(receiver, fieldRecord)
|
||||||
|
1. Assert: Type(receiver) is Object.
|
||||||
|
2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation.
|
||||||
|
3. Let name be fieldRecord.[[Name]].
|
||||||
|
4. Let initializer be fieldRecord.[[Initializer]].
|
||||||
|
5. If initializer is not empty, then
|
||||||
|
a. Let initValue be ? Call(initializer, receiver).
|
||||||
|
...
|
||||||
|
template: default
|
||||||
|
features: [class-static-fields-private, class-static-fields-public]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- elements
|
||||||
|
static #field = (a, b) => undefined;
|
||||||
|
static field = function() {};
|
||||||
|
|
||||||
|
static accessPrivateField() {
|
||||||
|
return this.#field;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- assertions
|
||||||
|
assert.sameValue(C.accessPrivateField().length, 2);
|
||||||
|
assert.sameValue(C.field.length, 0);
|
|
@ -0,0 +1,46 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/class-elements/fields-anonymous-function-length.case
|
||||||
|
// - src/class-elements/default/cls-expr.template
|
||||||
|
/*---
|
||||||
|
description: Anonymous function in field initilizer have length properly set (field definitions in a class expression)
|
||||||
|
esid: prod-FieldDefinition
|
||||||
|
features: [class-static-fields-private, class-static-fields-public, class]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
FieldDefinition :
|
||||||
|
ClassElementName Initializer_opt
|
||||||
|
|
||||||
|
InitializeInstanceFields ( O, constructor )
|
||||||
|
1. Assert: Type ( O ) is Object.
|
||||||
|
2. Assert: constructor is an ECMAScript function object.
|
||||||
|
3. Let fields be the value of constructor.[[Fields]].
|
||||||
|
4. For each item fieldRecord in order from fields,
|
||||||
|
a. Perform ? DefineField(O, fieldRecord).
|
||||||
|
5. Return.
|
||||||
|
|
||||||
|
DefineField(receiver, fieldRecord)
|
||||||
|
1. Assert: Type(receiver) is Object.
|
||||||
|
2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation.
|
||||||
|
3. Let name be fieldRecord.[[Name]].
|
||||||
|
4. Let initializer be fieldRecord.[[Initializer]].
|
||||||
|
5. If initializer is not empty, then
|
||||||
|
a. Let initValue be ? Call(initializer, receiver).
|
||||||
|
...
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
|
||||||
|
var C = class {
|
||||||
|
field = function() {};
|
||||||
|
#field = (a, b, c, d) => undefined;
|
||||||
|
|
||||||
|
accessPrivateField() {
|
||||||
|
return this.#field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let c = new C();
|
||||||
|
assert.sameValue(c.accessPrivateField().length, 4);
|
||||||
|
assert.sameValue(c.field.length, 0);
|
|
@ -0,0 +1,47 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/class-elements/private-method-length.case
|
||||||
|
// - src/class-elements/default/cls-expr.template
|
||||||
|
/*---
|
||||||
|
description: Private methods have length property properly configured (field definitions in a class expression)
|
||||||
|
esid: prod-FieldDefinition
|
||||||
|
features: [class-methods-private, class]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype".
|
||||||
|
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static".
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject.
|
||||||
|
2. ReturnIfAbrupt(methodDef).
|
||||||
|
3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable).
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable.
|
||||||
|
2. Return empty.
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName (UniqueFormalParameters) { FunctionBody }
|
||||||
|
...
|
||||||
|
8. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, privateScope, strict, prototype).
|
||||||
|
9. Perform MakeMethod(closure, object).
|
||||||
|
10. Return the Record{[[Key]]: propKey, [[Closure]]: closure}.
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
|
||||||
|
var C = class {
|
||||||
|
#method(a) {};
|
||||||
|
|
||||||
|
getPrivateMethod() {
|
||||||
|
return this.#method;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let c = new C();
|
||||||
|
assert.sameValue(c.getPrivateMethod().length, 1);
|
|
@ -0,0 +1,46 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/class-elements/private-static-method-length.case
|
||||||
|
// - src/class-elements/default/cls-expr.template
|
||||||
|
/*---
|
||||||
|
description: Private static methods have length property properly configured (field definitions in a class expression)
|
||||||
|
esid: prod-FieldDefinition
|
||||||
|
features: [class-static-methods-private, class]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype".
|
||||||
|
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static".
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject.
|
||||||
|
2. ReturnIfAbrupt(methodDef).
|
||||||
|
3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable).
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable.
|
||||||
|
2. Return empty.
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName (UniqueFormalParameters) { FunctionBody }
|
||||||
|
...
|
||||||
|
8. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, privateScope, strict, prototype).
|
||||||
|
9. Perform MakeMethod(closure, object).
|
||||||
|
10. Return the Record{[[Key]]: propKey, [[Closure]]: closure}.
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
|
||||||
|
var C = class {
|
||||||
|
static #method(a, b, c) {};
|
||||||
|
|
||||||
|
static getPrivateMethod() {
|
||||||
|
return this.#method;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(C.getPrivateMethod().length, 3);
|
|
@ -0,0 +1,61 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/class-elements/static-field-anonymous-function-length.case
|
||||||
|
// - src/class-elements/default/cls-expr.template
|
||||||
|
/*---
|
||||||
|
description: Anonymous function in field initilizer have length properly set (field definitions in a class expression)
|
||||||
|
esid: prod-FieldDefinition
|
||||||
|
features: [class-static-fields-private, class-static-fields-public, class]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
ClassElement :
|
||||||
|
...
|
||||||
|
static FieldDefinition ;
|
||||||
|
|
||||||
|
FieldDefinition :
|
||||||
|
ClassElementName Initializer_opt
|
||||||
|
|
||||||
|
ClassDefinitionEvaluation:
|
||||||
|
...
|
||||||
|
|
||||||
|
27. Let staticFields be a new empty List.
|
||||||
|
28. For each ClassElement e in order from elements,
|
||||||
|
a. If IsStatic of e is false, then
|
||||||
|
...
|
||||||
|
b. Else,
|
||||||
|
i. Let field be the result of performing PropertyDefinitionEvaluation for m ClassElementEvaluation for e with arguments F and false.
|
||||||
|
c. If field is an abrupt completion, then
|
||||||
|
...
|
||||||
|
d. If field is not empty,
|
||||||
|
i. If IsStatic of e is false, append field to instanceFields.
|
||||||
|
ii. Otherwise, append field to staticFields.
|
||||||
|
|
||||||
|
34. For each item fieldRecord in order from staticFields,
|
||||||
|
a. Perform ? DefineField(F, field).
|
||||||
|
...
|
||||||
|
|
||||||
|
DefineField(receiver, fieldRecord)
|
||||||
|
1. Assert: Type(receiver) is Object.
|
||||||
|
2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation.
|
||||||
|
3. Let name be fieldRecord.[[Name]].
|
||||||
|
4. Let initializer be fieldRecord.[[Initializer]].
|
||||||
|
5. If initializer is not empty, then
|
||||||
|
a. Let initValue be ? Call(initializer, receiver).
|
||||||
|
...
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
|
||||||
|
var C = class {
|
||||||
|
static #field = (a, b) => undefined;
|
||||||
|
static field = function() {};
|
||||||
|
|
||||||
|
static accessPrivateField() {
|
||||||
|
return this.#field;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(C.accessPrivateField().length, 2);
|
||||||
|
assert.sameValue(C.field.length, 0);
|
|
@ -0,0 +1,46 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/class-elements/fields-anonymous-function-length.case
|
||||||
|
// - src/class-elements/default/cls-decl.template
|
||||||
|
/*---
|
||||||
|
description: Anonymous function in field initilizer have length properly set (field definitions in a class declaration)
|
||||||
|
esid: prod-FieldDefinition
|
||||||
|
features: [class-static-fields-private, class-static-fields-public, class]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
FieldDefinition :
|
||||||
|
ClassElementName Initializer_opt
|
||||||
|
|
||||||
|
InitializeInstanceFields ( O, constructor )
|
||||||
|
1. Assert: Type ( O ) is Object.
|
||||||
|
2. Assert: constructor is an ECMAScript function object.
|
||||||
|
3. Let fields be the value of constructor.[[Fields]].
|
||||||
|
4. For each item fieldRecord in order from fields,
|
||||||
|
a. Perform ? DefineField(O, fieldRecord).
|
||||||
|
5. Return.
|
||||||
|
|
||||||
|
DefineField(receiver, fieldRecord)
|
||||||
|
1. Assert: Type(receiver) is Object.
|
||||||
|
2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation.
|
||||||
|
3. Let name be fieldRecord.[[Name]].
|
||||||
|
4. Let initializer be fieldRecord.[[Initializer]].
|
||||||
|
5. If initializer is not empty, then
|
||||||
|
a. Let initValue be ? Call(initializer, receiver).
|
||||||
|
...
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
|
||||||
|
class C {
|
||||||
|
field = function() {};
|
||||||
|
#field = (a, b, c, d) => undefined;
|
||||||
|
|
||||||
|
accessPrivateField() {
|
||||||
|
return this.#field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let c = new C();
|
||||||
|
assert.sameValue(c.accessPrivateField().length, 4);
|
||||||
|
assert.sameValue(c.field.length, 0);
|
|
@ -0,0 +1,47 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/class-elements/private-method-length.case
|
||||||
|
// - src/class-elements/default/cls-decl.template
|
||||||
|
/*---
|
||||||
|
description: Private methods have length property properly configured (field definitions in a class declaration)
|
||||||
|
esid: prod-FieldDefinition
|
||||||
|
features: [class-methods-private, class]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype".
|
||||||
|
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static".
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject.
|
||||||
|
2. ReturnIfAbrupt(methodDef).
|
||||||
|
3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable).
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable.
|
||||||
|
2. Return empty.
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName (UniqueFormalParameters) { FunctionBody }
|
||||||
|
...
|
||||||
|
8. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, privateScope, strict, prototype).
|
||||||
|
9. Perform MakeMethod(closure, object).
|
||||||
|
10. Return the Record{[[Key]]: propKey, [[Closure]]: closure}.
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
|
||||||
|
class C {
|
||||||
|
#method(a) {};
|
||||||
|
|
||||||
|
getPrivateMethod() {
|
||||||
|
return this.#method;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let c = new C();
|
||||||
|
assert.sameValue(c.getPrivateMethod().length, 1);
|
|
@ -0,0 +1,46 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/class-elements/private-static-method-length.case
|
||||||
|
// - src/class-elements/default/cls-decl.template
|
||||||
|
/*---
|
||||||
|
description: Private static methods have length property properly configured (field definitions in a class declaration)
|
||||||
|
esid: prod-FieldDefinition
|
||||||
|
features: [class-static-methods-private, class]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments ! Get(homeObject, "prototype"),enumerable, and "prototype".
|
||||||
|
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Return ClassElementEvaluation of MethodDefinition with arguments homeObject, enumerable and "static".
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName( UniqueFormalParameters ) { FunctionBody }
|
||||||
|
1. Let methodDef be DefineMethod of MethodDefinition with argument homeObject.
|
||||||
|
2. ReturnIfAbrupt(methodDef).
|
||||||
|
3. Perform ? DefineOrdinaryMethod(methodDef.[[Key]], homeObject, methodDef.[[Closure]], _enumerable).
|
||||||
|
|
||||||
|
ClassElement : MethodDefinition
|
||||||
|
ClassElement : static MethodDefinition
|
||||||
|
1. Perform ? PropertyDefinitionEvaluation with parameters object and enumerable.
|
||||||
|
2. Return empty.
|
||||||
|
|
||||||
|
MethodDefinition : ClassElementName (UniqueFormalParameters) { FunctionBody }
|
||||||
|
...
|
||||||
|
8. Let closure be FunctionCreate(kind, UniqueFormalParameters, FunctionBody, scope, privateScope, strict, prototype).
|
||||||
|
9. Perform MakeMethod(closure, object).
|
||||||
|
10. Return the Record{[[Key]]: propKey, [[Closure]]: closure}.
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static #method(a, b, c) {};
|
||||||
|
|
||||||
|
static getPrivateMethod() {
|
||||||
|
return this.#method;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(C.getPrivateMethod().length, 3);
|
|
@ -0,0 +1,61 @@
|
||||||
|
// This file was procedurally generated from the following sources:
|
||||||
|
// - src/class-elements/static-field-anonymous-function-length.case
|
||||||
|
// - src/class-elements/default/cls-decl.template
|
||||||
|
/*---
|
||||||
|
description: Anonymous function in field initilizer have length properly set (field definitions in a class declaration)
|
||||||
|
esid: prod-FieldDefinition
|
||||||
|
features: [class-static-fields-private, class-static-fields-public, class]
|
||||||
|
flags: [generated]
|
||||||
|
info: |
|
||||||
|
Updated Productions
|
||||||
|
|
||||||
|
ClassElement :
|
||||||
|
...
|
||||||
|
static FieldDefinition ;
|
||||||
|
|
||||||
|
FieldDefinition :
|
||||||
|
ClassElementName Initializer_opt
|
||||||
|
|
||||||
|
ClassDefinitionEvaluation:
|
||||||
|
...
|
||||||
|
|
||||||
|
27. Let staticFields be a new empty List.
|
||||||
|
28. For each ClassElement e in order from elements,
|
||||||
|
a. If IsStatic of e is false, then
|
||||||
|
...
|
||||||
|
b. Else,
|
||||||
|
i. Let field be the result of performing PropertyDefinitionEvaluation for m ClassElementEvaluation for e with arguments F and false.
|
||||||
|
c. If field is an abrupt completion, then
|
||||||
|
...
|
||||||
|
d. If field is not empty,
|
||||||
|
i. If IsStatic of e is false, append field to instanceFields.
|
||||||
|
ii. Otherwise, append field to staticFields.
|
||||||
|
|
||||||
|
34. For each item fieldRecord in order from staticFields,
|
||||||
|
a. Perform ? DefineField(F, field).
|
||||||
|
...
|
||||||
|
|
||||||
|
DefineField(receiver, fieldRecord)
|
||||||
|
1. Assert: Type(receiver) is Object.
|
||||||
|
2. Assert: fieldRecord is a Record as created by ClassFieldDefinitionEvaluation.
|
||||||
|
3. Let name be fieldRecord.[[Name]].
|
||||||
|
4. Let initializer be fieldRecord.[[Initializer]].
|
||||||
|
5. If initializer is not empty, then
|
||||||
|
a. Let initValue be ? Call(initializer, receiver).
|
||||||
|
...
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static #field = (a, b) => undefined;
|
||||||
|
static field = function() {};
|
||||||
|
|
||||||
|
static accessPrivateField() {
|
||||||
|
return this.#field;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(C.accessPrivateField().length, 2);
|
||||||
|
assert.sameValue(C.field.length, 0);
|
Loading…
Reference in New Issue