mirror of
https://github.com/tc39/test262.git
synced 2025-05-30 11:40:30 +02:00
Add private methods test templates
This commit is contained in:
parent
69c1efd325
commit
5e217d531e
26
src/accessor-names/default/cls-private-decl-inst.template
Normal file
26
src/accessor-names/default/cls-private-decl-inst.template
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2017 Mike Pennisi. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
path: language/statements/class/accessor-name-inst-
|
||||||
|
name: Class declaration, instance method
|
||||||
|
esid: sec-runtime-semantics-classdefinitionevaluation
|
||||||
|
es6id: 14.5.14
|
||||||
|
info: |
|
||||||
|
[...]
|
||||||
|
21. For each ClassElement m in order from methods
|
||||||
|
a. If IsStatic of m is false, then
|
||||||
|
i. Let status be the result of performing PropertyDefinitionEvaluation
|
||||||
|
for m with arguments proto and false.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var stringSet;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
get /*{ declareWith }*/() { return 'get string'; }
|
||||||
|
set /*{ declareWith }*/(param) { stringSet = param; }
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(C.prototype[/*{ referenceWith }*/], 'get string');
|
||||||
|
|
||||||
|
C.prototype[/*{ referenceWith }*/] = 'set string';
|
||||||
|
assert.sameValue(stringSet, 'set string');
|
46
src/accessor-names/default/cls-private-decl-static.template
Normal file
46
src/accessor-names/default/cls-private-decl-static.template
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright (C) 2018 Katie Broida. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
path: language/statements/class/private-accessor-name-static-
|
||||||
|
name: Class declaration, static method
|
||||||
|
esid: #prod-MethodDefinition
|
||||||
|
info: |
|
||||||
|
[...]
|
||||||
|
MethodDefinition[Yield, Await]:
|
||||||
|
PropertyNameClassElementName [?Yield, ?Await](
|
||||||
|
UniqueFormalParameters [~Yield, ~Await] ) {
|
||||||
|
FunctionBody [~Yield, ~Await] }
|
||||||
|
AsyncMethod[?Yield, ?Await]
|
||||||
|
get PropertyName ClassElementName [?Yield, ?Await] (){
|
||||||
|
FunctionBody [~Yield, ~Await] }
|
||||||
|
set PropertyNameClassElementName [?Yield, ?Await] (
|
||||||
|
PropertySetParameterList ) { FunctionBody [~Yield, ~Await] }
|
||||||
|
AsyncMethod [Yield, Await]:
|
||||||
|
async [no LineTerminator here] PropertyName
|
||||||
|
ClassElementName[?Yield, ?Await](
|
||||||
|
UniqueFormalParameters[~Yield, +Await] ) { AsyncFunctionBody }
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var stringSet;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
static get #/*{ declareWith }*/() { return 'get string'; }
|
||||||
|
static set #/*{ declareWith }*/(param) { stringSet = param; }
|
||||||
|
|
||||||
|
static getPrivateReference() {
|
||||||
|
return this.#/*{ referenceWith }*/;
|
||||||
|
}
|
||||||
|
|
||||||
|
static setPrivateReference(value) {
|
||||||
|
this.#/*{ referenceWith }*/ = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var inst = C();
|
||||||
|
|
||||||
|
assert.sameValue(inst.getPrivateReference(), 'get string');
|
||||||
|
|
||||||
|
inst.setPrivateReference('set string');
|
||||||
|
assert.sameValue(stringSet, 'set string');
|
||||||
|
|
45
src/accessor-names/default/cls-private-expr-inst.template
Normal file
45
src/accessor-names/default/cls-private-expr-inst.template
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (C) 2018 Katie Broida. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
path: language/expressions/class/private-accessor-name-inst-
|
||||||
|
name: Class expression, instance private method
|
||||||
|
esid: #prod-MethodDefinition
|
||||||
|
info: |
|
||||||
|
[...]
|
||||||
|
MethodDefinition[Yield, Await]:
|
||||||
|
PropertyNameClassElementName [?Yield, ?Await](
|
||||||
|
UniqueFormalParameters [~Yield, ~Await] ) {
|
||||||
|
FunctionBody [~Yield, ~Await] }
|
||||||
|
AsyncMethod[?Yield, ?Await]
|
||||||
|
get PropertyName ClassElementName [?Yield, ?Await] (){
|
||||||
|
FunctionBody [~Yield, ~Await] }
|
||||||
|
set PropertyNameClassElementName [?Yield, ?Await] (
|
||||||
|
PropertySetParameterList ) { FunctionBody [~Yield, ~Await] }
|
||||||
|
AsyncMethod [Yield, Await]:
|
||||||
|
async [no LineTerminator here] PropertyName
|
||||||
|
ClassElementName[?Yield, ?Await](
|
||||||
|
UniqueFormalParameters[~Yield, +Await] ) { AsyncFunctionBody }
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var stringSet;
|
||||||
|
|
||||||
|
var C = class {
|
||||||
|
get #/*{ declareWith }*/() { return 'get string'; }
|
||||||
|
set #/*{ declareWith }*/(param) { stringSet = param; }
|
||||||
|
|
||||||
|
getPrivateReference() {
|
||||||
|
return this.#/*{ referenceWith }*/;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPrivateReference(value) {
|
||||||
|
this.#/*{ referenceWith }*/ = value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var inst = C();
|
||||||
|
|
||||||
|
assert.sameValue(inst.getPrivateReference(), 'get string');
|
||||||
|
|
||||||
|
inst.setPrivateReference('set string');
|
||||||
|
assert.sameValue(stringSet, 'set string');
|
45
src/accessor-names/default/cls-private-expr-static.template
Normal file
45
src/accessor-names/default/cls-private-expr-static.template
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (C) 2018 Katie Broida. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
path: language/expressions/class/private-accessor-name-static-
|
||||||
|
name: Class expression, static private method
|
||||||
|
esid: #prod-MethodDefinition
|
||||||
|
info: |
|
||||||
|
[...]
|
||||||
|
MethodDefinition[Yield, Await]:
|
||||||
|
PropertyNameClassElementName [?Yield, ?Await](
|
||||||
|
UniqueFormalParameters [~Yield, ~Await] ) {
|
||||||
|
FunctionBody [~Yield, ~Await] }
|
||||||
|
AsyncMethod[?Yield, ?Await]
|
||||||
|
get PropertyName ClassElementName [?Yield, ?Await] (){
|
||||||
|
FunctionBody [~Yield, ~Await] }
|
||||||
|
set PropertyNameClassElementName [?Yield, ?Await] (
|
||||||
|
PropertySetParameterList ) { FunctionBody [~Yield, ~Await] }
|
||||||
|
AsyncMethod [Yield, Await]:
|
||||||
|
async [no LineTerminator here] PropertyName
|
||||||
|
ClassElementName[?Yield, ?Await](
|
||||||
|
UniqueFormalParameters[~Yield, +Await] ) { AsyncFunctionBody }
|
||||||
|
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var stringSet;
|
||||||
|
|
||||||
|
var C = class {
|
||||||
|
static get #/*{ declareWith }*/() { return 'get string'; }
|
||||||
|
static set #/*{ declareWith }*/(param) { stringSet = param; }
|
||||||
|
|
||||||
|
static getPrivateReference() {
|
||||||
|
return this.#/*{ referenceWith }*/;
|
||||||
|
}
|
||||||
|
|
||||||
|
static setPrivateReference(value) {
|
||||||
|
this.#/*{ referenceWith }*/ = value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var inst = C();
|
||||||
|
|
||||||
|
assert.sameValue(inst.getPrivateReference(), 'get string');
|
||||||
|
|
||||||
|
inst.setPrivateReference('set string');
|
||||||
|
assert.sameValue(stringSet, 'set string');
|
Loading…
x
Reference in New Issue
Block a user