mirror of https://github.com/tc39/test262.git
Refactor templates to assert valid private accessor method names
This commit is contained in:
parent
f11d0ab3d5
commit
23be7aac3f
|
@ -1,45 +0,0 @@
|
||||||
// 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-inst-
|
|
||||||
name: Class declaration, private instance 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 {
|
|
||||||
get #/*{ declareWith }*/() { return 'get string'; }
|
|
||||||
set #/*{ declareWith }*/(param) { stringSet = param; }
|
|
||||||
|
|
||||||
getPrivateReference() {
|
|
||||||
return this[#/*{ referenceWith }*/];
|
|
||||||
}
|
|
||||||
|
|
||||||
setPrivateReference(value) {
|
|
||||||
this[#/*{ referenceWith }*/] = value;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var inst = new C();
|
|
||||||
|
|
||||||
assert.sameValue(inst.getPrivateReference(), 'get string');
|
|
||||||
|
|
||||||
inst.setPrivateReference('set string');
|
|
||||||
assert.sameValue(stringSet, 'set string');
|
|
|
@ -1,44 +0,0 @@
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assert.sameValue(C.getPrivateReference(), 'get string');
|
|
||||||
|
|
||||||
C.setPrivateReference('set string');
|
|
||||||
assert.sameValue(stringSet, 'set string');
|
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
// 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 = new C();
|
|
||||||
|
|
||||||
assert.sameValue(inst.getPrivateReference(), 'get string');
|
|
||||||
|
|
||||||
inst.setPrivateReference('set string');
|
|
||||||
assert.sameValue(stringSet, 'set string');
|
|
|
@ -1,44 +0,0 @@
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
assert.sameValue(C.getPrivateReference(), 'get string');
|
|
||||||
|
|
||||||
C.setPrivateReference('set string');
|
|
||||||
assert.sameValue(stringSet, 'set string');
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private IdentifierName - ZWJ
|
||||||
|
esid: sec-private-names-static-semantics-stringvalue
|
||||||
|
template: private
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- declareWith
|
||||||
|
ZW_\u200D_J
|
||||||
|
//- referenceWith
|
||||||
|
ZW__J
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private IdentifierName - ZWNJ
|
||||||
|
esid: sec-private-names-static-semantics-stringvalue
|
||||||
|
template: private
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- declareWith
|
||||||
|
ZW_\u200C_NJ
|
||||||
|
//- referenceWith
|
||||||
|
ZW__NJ
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private IdentifierName - u2118 (℘)
|
||||||
|
esid: sec-private-names-static-semantics-stringvalue
|
||||||
|
template: private
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- declareWith
|
||||||
|
\u2118
|
||||||
|
//- referenceWith
|
||||||
|
℘
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private IdentifierName - u6F (o)
|
||||||
|
esid: sec-private-names-static-semantics-stringvalue
|
||||||
|
template: private
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- declareWith
|
||||||
|
\u{6F}
|
||||||
|
//- referenceWith
|
||||||
|
o
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private IdentifierName - ZWJ
|
||||||
|
esid: sec-private-names-static-semantics-stringvalue
|
||||||
|
template: private
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- declareWith
|
||||||
|
ZW__J
|
||||||
|
//- referenceWith
|
||||||
|
ZW__J
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private IdentifierName - ZWNJ
|
||||||
|
esid: sec-private-names-static-semantics-stringvalue
|
||||||
|
template: private
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- declareWith
|
||||||
|
ZW__NJ
|
||||||
|
//- referenceWith
|
||||||
|
ZW__NJ
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private IdentifierName - common
|
||||||
|
esid: sec-private-names-static-semantics-stringvalue
|
||||||
|
template: private
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- declareWith
|
||||||
|
test262
|
||||||
|
//- referenceWith
|
||||||
|
test262
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private IdentifierName - $
|
||||||
|
esid: sec-private-names-static-semantics-stringvalue
|
||||||
|
template: private
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- declareWith
|
||||||
|
$
|
||||||
|
//- referenceWith
|
||||||
|
$
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private IdentifierName - ℘
|
||||||
|
esid: sec-private-names-static-semantics-stringvalue
|
||||||
|
template: private
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- declareWith
|
||||||
|
℘
|
||||||
|
//- referenceWith
|
||||||
|
℘
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright (C) 2018 Leo Balter. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
desc: Private IdentifierName - _
|
||||||
|
esid: sec-private-names-static-semantics-stringvalue
|
||||||
|
template: private
|
||||||
|
---*/
|
||||||
|
|
||||||
|
//- declareWith
|
||||||
|
_
|
||||||
|
//- referenceWith
|
||||||
|
_
|
|
@ -0,0 +1,77 @@
|
||||||
|
// 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/inst-
|
||||||
|
name: Class declaration, private instance method
|
||||||
|
esid: #prod-MethodDefinition
|
||||||
|
info: |
|
||||||
|
ClassElement :
|
||||||
|
MethodDefinition
|
||||||
|
static MethodDefinition
|
||||||
|
FieldDefinition ;
|
||||||
|
;
|
||||||
|
|
||||||
|
FieldDefinition :
|
||||||
|
ClassElementName Initializer _opt
|
||||||
|
|
||||||
|
ClassElementName :
|
||||||
|
PropertyName
|
||||||
|
PrivateName
|
||||||
|
|
||||||
|
PrivateName ::
|
||||||
|
# IdentifierName
|
||||||
|
|
||||||
|
Initializer :
|
||||||
|
= AssignmentExpression
|
||||||
|
|
||||||
|
IdentifierName ::
|
||||||
|
IdentifierStart
|
||||||
|
IdentifierName IdentifierPart
|
||||||
|
|
||||||
|
IdentifierStart ::
|
||||||
|
UnicodeIDStart
|
||||||
|
$
|
||||||
|
_
|
||||||
|
\ UnicodeEscapeSequence
|
||||||
|
|
||||||
|
IdentifierPart::
|
||||||
|
UnicodeIDContinue
|
||||||
|
$
|
||||||
|
\ UnicodeEscapeSequence
|
||||||
|
<ZWNJ> <ZWJ>
|
||||||
|
|
||||||
|
UnicodeIDStart::
|
||||||
|
any Unicode code point with the Unicode property "ID_Start"
|
||||||
|
|
||||||
|
UnicodeIDContinue::
|
||||||
|
any Unicode code point with the Unicode property "ID_Continue"
|
||||||
|
|
||||||
|
|
||||||
|
NOTE 3
|
||||||
|
The sets of code points with Unicode properties "ID_Start" and
|
||||||
|
"ID_Continue" include, respectively, the code points with Unicode
|
||||||
|
properties "Other_ID_Start" and "Other_ID_Continue".
|
||||||
|
features: [class-methods-private]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var stringSet;
|
||||||
|
|
||||||
|
class C {
|
||||||
|
get #/*{ declareWith }*/() { return 'get string'; }
|
||||||
|
set #/*{ declareWith }*/(param) { stringSet = param; }
|
||||||
|
|
||||||
|
getPrivateReference() {
|
||||||
|
return this.#/*{ referenceWith }*/;
|
||||||
|
}
|
||||||
|
|
||||||
|
setPrivateReference(value) {
|
||||||
|
this.#/*{ referenceWith }*/ = value;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var inst = new C();
|
||||||
|
|
||||||
|
assert.sameValue(inst.getPrivateReference(), 'get string');
|
||||||
|
|
||||||
|
inst.setPrivateReference('set string');
|
||||||
|
assert.sameValue(stringSet, 'set string');
|
|
@ -0,0 +1,76 @@
|
||||||
|
// 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: |
|
||||||
|
ClassElement :
|
||||||
|
MethodDefinition
|
||||||
|
static MethodDefinition
|
||||||
|
FieldDefinition ;
|
||||||
|
;
|
||||||
|
|
||||||
|
FieldDefinition :
|
||||||
|
ClassElementName Initializer _opt
|
||||||
|
|
||||||
|
ClassElementName :
|
||||||
|
PropertyName
|
||||||
|
PrivateName
|
||||||
|
|
||||||
|
PrivateName ::
|
||||||
|
# IdentifierName
|
||||||
|
|
||||||
|
Initializer :
|
||||||
|
= AssignmentExpression
|
||||||
|
|
||||||
|
IdentifierName ::
|
||||||
|
IdentifierStart
|
||||||
|
IdentifierName IdentifierPart
|
||||||
|
|
||||||
|
IdentifierStart ::
|
||||||
|
UnicodeIDStart
|
||||||
|
$
|
||||||
|
_
|
||||||
|
\ UnicodeEscapeSequence
|
||||||
|
|
||||||
|
IdentifierPart::
|
||||||
|
UnicodeIDContinue
|
||||||
|
$
|
||||||
|
\ UnicodeEscapeSequence
|
||||||
|
<ZWNJ> <ZWJ>
|
||||||
|
|
||||||
|
UnicodeIDStart::
|
||||||
|
any Unicode code point with the Unicode property "ID_Start"
|
||||||
|
|
||||||
|
UnicodeIDContinue::
|
||||||
|
any Unicode code point with the Unicode property "ID_Continue"
|
||||||
|
|
||||||
|
|
||||||
|
NOTE 3
|
||||||
|
The sets of code points with Unicode properties "ID_Start" and
|
||||||
|
"ID_Continue" include, respectively, the code points with Unicode
|
||||||
|
properties "Other_ID_Start" and "Other_ID_Continue".
|
||||||
|
features: [class-methods-private]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.sameValue(C.getPrivateReference(), 'get string');
|
||||||
|
|
||||||
|
C.setPrivateReference('set string');
|
||||||
|
assert.sameValue(stringSet, 'set string');
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
// 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: |
|
||||||
|
ClassElement :
|
||||||
|
MethodDefinition
|
||||||
|
static MethodDefinition
|
||||||
|
FieldDefinition ;
|
||||||
|
;
|
||||||
|
|
||||||
|
FieldDefinition :
|
||||||
|
ClassElementName Initializer _opt
|
||||||
|
|
||||||
|
ClassElementName :
|
||||||
|
PropertyName
|
||||||
|
PrivateName
|
||||||
|
|
||||||
|
PrivateName ::
|
||||||
|
# IdentifierName
|
||||||
|
|
||||||
|
Initializer :
|
||||||
|
= AssignmentExpression
|
||||||
|
|
||||||
|
IdentifierName ::
|
||||||
|
IdentifierStart
|
||||||
|
IdentifierName IdentifierPart
|
||||||
|
|
||||||
|
IdentifierStart ::
|
||||||
|
UnicodeIDStart
|
||||||
|
$
|
||||||
|
_
|
||||||
|
\ UnicodeEscapeSequence
|
||||||
|
|
||||||
|
IdentifierPart::
|
||||||
|
UnicodeIDContinue
|
||||||
|
$
|
||||||
|
\ UnicodeEscapeSequence
|
||||||
|
<ZWNJ> <ZWJ>
|
||||||
|
|
||||||
|
UnicodeIDStart::
|
||||||
|
any Unicode code point with the Unicode property "ID_Start"
|
||||||
|
|
||||||
|
UnicodeIDContinue::
|
||||||
|
any Unicode code point with the Unicode property "ID_Continue"
|
||||||
|
|
||||||
|
|
||||||
|
NOTE 3
|
||||||
|
The sets of code points with Unicode properties "ID_Start" and
|
||||||
|
"ID_Continue" include, respectively, the code points with Unicode
|
||||||
|
properties "Other_ID_Start" and "Other_ID_Continue".
|
||||||
|
features: [class-methods-private]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
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 = new C();
|
||||||
|
|
||||||
|
assert.sameValue(inst.getPrivateReference(), 'get string');
|
||||||
|
|
||||||
|
inst.setPrivateReference('set string');
|
||||||
|
assert.sameValue(stringSet, 'set string');
|
|
@ -0,0 +1,77 @@
|
||||||
|
// 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: |
|
||||||
|
ClassElement :
|
||||||
|
MethodDefinition
|
||||||
|
static MethodDefinition
|
||||||
|
FieldDefinition ;
|
||||||
|
;
|
||||||
|
|
||||||
|
MethodDefinition :
|
||||||
|
get ClassElementName () { FunctionBody }
|
||||||
|
set ClassElementName ( PropertySetParameterList ){ FunctionBody }
|
||||||
|
|
||||||
|
ClassElementName :
|
||||||
|
PropertyName
|
||||||
|
PrivateName
|
||||||
|
|
||||||
|
PrivateName ::
|
||||||
|
# IdentifierName
|
||||||
|
|
||||||
|
Initializer :
|
||||||
|
= AssignmentExpression
|
||||||
|
|
||||||
|
IdentifierName ::
|
||||||
|
IdentifierStart
|
||||||
|
IdentifierName IdentifierPart
|
||||||
|
|
||||||
|
IdentifierStart ::
|
||||||
|
UnicodeIDStart
|
||||||
|
$
|
||||||
|
_
|
||||||
|
\ UnicodeEscapeSequence
|
||||||
|
|
||||||
|
IdentifierPart::
|
||||||
|
UnicodeIDContinue
|
||||||
|
$
|
||||||
|
\ UnicodeEscapeSequence
|
||||||
|
<ZWNJ> <ZWJ>
|
||||||
|
|
||||||
|
UnicodeIDStart::
|
||||||
|
any Unicode code point with the Unicode property "ID_Start"
|
||||||
|
|
||||||
|
UnicodeIDContinue::
|
||||||
|
any Unicode code point with the Unicode property "ID_Continue"
|
||||||
|
|
||||||
|
|
||||||
|
NOTE 3
|
||||||
|
The sets of code points with Unicode properties "ID_Start" and
|
||||||
|
"ID_Continue" include, respectively, the code points with Unicode
|
||||||
|
properties "Other_ID_Start" and "Other_ID_Continue".
|
||||||
|
features: [class-methods-private]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
assert.sameValue(C.getPrivateReference(), 'get string');
|
||||||
|
|
||||||
|
C.setPrivateReference('set string');
|
||||||
|
assert.sameValue(stringSet, 'set string');
|
Loading…
Reference in New Issue