From 1b1097dbf6e93fb17b5a8156736563370ad4700e Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 11 Feb 2022 16:54:44 -0800 Subject: [PATCH] Add tests for compound assignment to private reference This tests compound assignment, with each compound assignment operator, to each kind of private reference (private field, private accessor property with getter and setter, private accessor property with only getter, and private method). The latter two cannot be assigned to and therefore throw. Closes: #2940 --- src/compound-assignment-private/add.case | 16 +++++ src/compound-assignment-private/and.case | 16 +++++ src/compound-assignment-private/bitand.case | 16 +++++ src/compound-assignment-private/bitor.case | 16 +++++ src/compound-assignment-private/bitxor.case | 16 +++++ .../default/data-property.template | 51 ++++++++++++++++ .../default/getter-setter.template | 59 ++++++++++++++++++ .../default/getter.template | 49 +++++++++++++++ .../default/method.template | 47 +++++++++++++++ src/compound-assignment-private/div.case | 16 +++++ src/compound-assignment-private/exp.case | 16 +++++ src/compound-assignment-private/lshift.case | 16 +++++ src/compound-assignment-private/mod.case | 16 +++++ src/compound-assignment-private/mult.case | 16 +++++ src/compound-assignment-private/nullish.case | 16 +++++ src/compound-assignment-private/or.case | 16 +++++ src/compound-assignment-private/rshift.case | 16 +++++ src/compound-assignment-private/srshift.case | 16 +++++ src/compound-assignment-private/sub.case | 16 +++++ ...private-reference-accessor-property-add.js | 60 +++++++++++++++++++ ...private-reference-accessor-property-and.js | 60 +++++++++++++++++++ ...vate-reference-accessor-property-bitand.js | 60 +++++++++++++++++++ ...ivate-reference-accessor-property-bitor.js | 60 +++++++++++++++++++ ...vate-reference-accessor-property-bitxor.js | 60 +++++++++++++++++++ ...private-reference-accessor-property-div.js | 60 +++++++++++++++++++ ...private-reference-accessor-property-exp.js | 60 +++++++++++++++++++ ...vate-reference-accessor-property-lshift.js | 60 +++++++++++++++++++ ...private-reference-accessor-property-mod.js | 60 +++++++++++++++++++ ...rivate-reference-accessor-property-mult.js | 60 +++++++++++++++++++ ...ate-reference-accessor-property-nullish.js | 60 +++++++++++++++++++ ...-private-reference-accessor-property-or.js | 60 +++++++++++++++++++ ...vate-reference-accessor-property-rshift.js | 60 +++++++++++++++++++ ...ate-reference-accessor-property-srshift.js | 60 +++++++++++++++++++ ...private-reference-accessor-property-sub.js | 60 +++++++++++++++++++ ...ide-private-reference-data-property-add.js | 52 ++++++++++++++++ ...ide-private-reference-data-property-and.js | 52 ++++++++++++++++ ...-private-reference-data-property-bitand.js | 52 ++++++++++++++++ ...e-private-reference-data-property-bitor.js | 52 ++++++++++++++++ ...-private-reference-data-property-bitxor.js | 52 ++++++++++++++++ ...ide-private-reference-data-property-div.js | 52 ++++++++++++++++ ...ide-private-reference-data-property-exp.js | 52 ++++++++++++++++ ...-private-reference-data-property-lshift.js | 52 ++++++++++++++++ ...ide-private-reference-data-property-mod.js | 52 ++++++++++++++++ ...de-private-reference-data-property-mult.js | 52 ++++++++++++++++ ...private-reference-data-property-nullish.js | 52 ++++++++++++++++ ...side-private-reference-data-property-or.js | 52 ++++++++++++++++ ...-private-reference-data-property-rshift.js | 52 ++++++++++++++++ ...private-reference-data-property-srshift.js | 52 ++++++++++++++++ ...ide-private-reference-data-property-sub.js | 52 ++++++++++++++++ ...-hand-side-private-reference-method-add.js | 48 +++++++++++++++ ...-hand-side-private-reference-method-and.js | 48 +++++++++++++++ ...nd-side-private-reference-method-bitand.js | 48 +++++++++++++++ ...and-side-private-reference-method-bitor.js | 48 +++++++++++++++ ...nd-side-private-reference-method-bitxor.js | 48 +++++++++++++++ ...-hand-side-private-reference-method-div.js | 48 +++++++++++++++ ...-hand-side-private-reference-method-exp.js | 48 +++++++++++++++ ...nd-side-private-reference-method-lshift.js | 48 +++++++++++++++ ...-hand-side-private-reference-method-mod.js | 48 +++++++++++++++ ...hand-side-private-reference-method-mult.js | 48 +++++++++++++++ ...d-side-private-reference-method-nullish.js | 48 +++++++++++++++ ...t-hand-side-private-reference-method-or.js | 48 +++++++++++++++ ...nd-side-private-reference-method-rshift.js | 48 +++++++++++++++ ...d-side-private-reference-method-srshift.js | 48 +++++++++++++++ ...-hand-side-private-reference-method-sub.js | 48 +++++++++++++++ ...eference-readonly-accessor-property-add.js | 50 ++++++++++++++++ ...eference-readonly-accessor-property-and.js | 50 ++++++++++++++++ ...rence-readonly-accessor-property-bitand.js | 50 ++++++++++++++++ ...erence-readonly-accessor-property-bitor.js | 50 ++++++++++++++++ ...rence-readonly-accessor-property-bitxor.js | 50 ++++++++++++++++ ...eference-readonly-accessor-property-div.js | 50 ++++++++++++++++ ...eference-readonly-accessor-property-exp.js | 50 ++++++++++++++++ ...rence-readonly-accessor-property-lshift.js | 50 ++++++++++++++++ ...eference-readonly-accessor-property-mod.js | 50 ++++++++++++++++ ...ference-readonly-accessor-property-mult.js | 50 ++++++++++++++++ ...ence-readonly-accessor-property-nullish.js | 50 ++++++++++++++++ ...reference-readonly-accessor-property-or.js | 50 ++++++++++++++++ ...rence-readonly-accessor-property-rshift.js | 50 ++++++++++++++++ ...ence-readonly-accessor-property-srshift.js | 50 ++++++++++++++++ ...eference-readonly-accessor-property-sub.js | 50 ++++++++++++++++ 79 files changed, 3596 insertions(+) create mode 100644 src/compound-assignment-private/add.case create mode 100644 src/compound-assignment-private/and.case create mode 100644 src/compound-assignment-private/bitand.case create mode 100644 src/compound-assignment-private/bitor.case create mode 100644 src/compound-assignment-private/bitxor.case create mode 100644 src/compound-assignment-private/default/data-property.template create mode 100644 src/compound-assignment-private/default/getter-setter.template create mode 100644 src/compound-assignment-private/default/getter.template create mode 100644 src/compound-assignment-private/default/method.template create mode 100644 src/compound-assignment-private/div.case create mode 100644 src/compound-assignment-private/exp.case create mode 100644 src/compound-assignment-private/lshift.case create mode 100644 src/compound-assignment-private/mod.case create mode 100644 src/compound-assignment-private/mult.case create mode 100644 src/compound-assignment-private/nullish.case create mode 100644 src/compound-assignment-private/or.case create mode 100644 src/compound-assignment-private/rshift.case create mode 100644 src/compound-assignment-private/srshift.case create mode 100644 src/compound-assignment-private/sub.case create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-add.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-and.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitand.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitor.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitxor.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-div.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-exp.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-lshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-mod.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-mult.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-nullish.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-or.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-rshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-srshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-sub.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-add.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-and.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitand.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitor.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitxor.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-div.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-exp.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-lshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-mod.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-mult.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-nullish.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-or.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-rshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-srshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-sub.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-add.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-and.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitand.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitor.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitxor.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-div.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-exp.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-lshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-mod.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-mult.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-nullish.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-or.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-rshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-srshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-method-sub.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-add.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-and.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitand.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitor.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitxor.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-div.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-exp.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-lshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-mod.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-mult.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-nullish.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-or.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-rshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-srshift.js create mode 100644 test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-sub.js diff --git a/src/compound-assignment-private/add.case b/src/compound-assignment-private/add.case new file mode 100644 index 0000000000..cb82184567 --- /dev/null +++ b/src/compound-assignment-private/add.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound addition assignment with target being a private reference +---*/ + +//- lhs +1 +//- operator ++= +//- rhs +2 +//- result +3 diff --git a/src/compound-assignment-private/and.case b/src/compound-assignment-private/and.case new file mode 100644 index 0000000000..8b43109758 --- /dev/null +++ b/src/compound-assignment-private/and.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound logical-and assignment with target being a private reference +---*/ + +//- lhs +true +//- operator +&&= +//- rhs +false +//- result +false diff --git a/src/compound-assignment-private/bitand.case b/src/compound-assignment-private/bitand.case new file mode 100644 index 0000000000..80e6735bd0 --- /dev/null +++ b/src/compound-assignment-private/bitand.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound bitwise-and assignment with target being a private reference +---*/ + +//- lhs +0b0101 +//- operator +&= +//- rhs +0b1010 +//- result +0b0000 diff --git a/src/compound-assignment-private/bitor.case b/src/compound-assignment-private/bitor.case new file mode 100644 index 0000000000..21e69195a6 --- /dev/null +++ b/src/compound-assignment-private/bitor.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound bitwise-or assignment with target being a private reference +---*/ + +//- lhs +0b0101 +//- operator +|= +//- rhs +0b1010 +//- result +0b1111 diff --git a/src/compound-assignment-private/bitxor.case b/src/compound-assignment-private/bitxor.case new file mode 100644 index 0000000000..0c9a54d6ad --- /dev/null +++ b/src/compound-assignment-private/bitxor.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound bitwise-xor assignment with target being a private reference +---*/ + +//- lhs +0x1111 +//- operator +^= +//- rhs +0x1010 +//- result +0x0101 diff --git a/src/compound-assignment-private/default/data-property.template b/src/compound-assignment-private/default/data-property.template new file mode 100644 index 0000000000..bdfca7bece --- /dev/null +++ b/src/compound-assignment-private/default/data-property.template @@ -0,0 +1,51 @@ +// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/compound-assignment/left-hand-side-private-reference-data-property- +esid: sec-assignment-operators-runtime-semantics-evaluation +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +name: to a field +features: [class-fields-private] +---*/ + +class C { + #field = /*{lhs}*/; + compoundAssignment() { + return this.#field /*{operator}*/ /*{rhs}*/; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), /*{result}*/, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), /*{result}*/, "PutValue should store the result in the private reference"); diff --git a/src/compound-assignment-private/default/getter-setter.template b/src/compound-assignment-private/default/getter-setter.template new file mode 100644 index 0000000000..3abe680cfa --- /dev/null +++ b/src/compound-assignment-private/default/getter-setter.template @@ -0,0 +1,59 @@ +// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property- +esid: sec-assignment-operators-runtime-semantics-evaluation +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +name: to an accessor property with getter and setter +features: [class-fields-private] +---*/ + +class C { + #setterCalledWith; + get #field() { + return /*{lhs}*/; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field /*{operator}*/ /*{rhs}*/; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), /*{result}*/, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), /*{result}*/, "PutValue should call the setter with the result"); diff --git a/src/compound-assignment-private/default/getter.template b/src/compound-assignment-private/default/getter.template new file mode 100644 index 0000000000..cfccdd0c28 --- /dev/null +++ b/src/compound-assignment-private/default/getter.template @@ -0,0 +1,49 @@ +// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property- +esid: sec-assignment-operators-runtime-semantics-evaluation +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +name: to an accessor property with getter +features: [class-fields-private] +---*/ + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field /*{operator}*/ 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/src/compound-assignment-private/default/method.template b/src/compound-assignment-private/default/method.template new file mode 100644 index 0000000000..7d43c04ec8 --- /dev/null +++ b/src/compound-assignment-private/default/method.template @@ -0,0 +1,47 @@ +// Copyright 2021 the V8 project authors; 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/compound-assignment/left-hand-side-private-reference-method- +esid: sec-assignment-operators-runtime-semantics-evaluation +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +name: to a private method +features: [class-fields-private] +---*/ + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod /*{operator}*/ 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/src/compound-assignment-private/div.case b/src/compound-assignment-private/div.case new file mode 100644 index 0000000000..c1b009efc0 --- /dev/null +++ b/src/compound-assignment-private/div.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound division assignment with target being a private reference +---*/ + +//- lhs +1 +//- operator +/= +//- rhs +2 +//- result +0.5 diff --git a/src/compound-assignment-private/exp.case b/src/compound-assignment-private/exp.case new file mode 100644 index 0000000000..abe58ceaf6 --- /dev/null +++ b/src/compound-assignment-private/exp.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound exponentiation assignment with target being a private reference +---*/ + +//- lhs +10 +//- operator +**= +//- rhs +3 +//- result +1000 diff --git a/src/compound-assignment-private/lshift.case b/src/compound-assignment-private/lshift.case new file mode 100644 index 0000000000..32014a8785 --- /dev/null +++ b/src/compound-assignment-private/lshift.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound left-shift assignment with target being a private reference +---*/ + +//- lhs +0b0110 +//- operator +<<= +//- rhs +4 +//- result +0b01100000 diff --git a/src/compound-assignment-private/mod.case b/src/compound-assignment-private/mod.case new file mode 100644 index 0000000000..a09d3d5171 --- /dev/null +++ b/src/compound-assignment-private/mod.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound modulo assignment with target being a private reference +---*/ + +//- lhs +3 +//- operator +%= +//- rhs +2 +//- result +1 diff --git a/src/compound-assignment-private/mult.case b/src/compound-assignment-private/mult.case new file mode 100644 index 0000000000..577693e788 --- /dev/null +++ b/src/compound-assignment-private/mult.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound multiplication assignment with target being a private reference +---*/ + +//- lhs +2 +//- operator +*= +//- rhs +3 +//- result +6 diff --git a/src/compound-assignment-private/nullish.case b/src/compound-assignment-private/nullish.case new file mode 100644 index 0000000000..7d49031ef8 --- /dev/null +++ b/src/compound-assignment-private/nullish.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound nullish-coalescing assignment with target being a private reference +---*/ + +//- lhs +null +//- operator +??= +//- rhs +1 +//- result +1 diff --git a/src/compound-assignment-private/or.case b/src/compound-assignment-private/or.case new file mode 100644 index 0000000000..a620b97fe0 --- /dev/null +++ b/src/compound-assignment-private/or.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound logical-or assignment with target being a private reference +---*/ + +//- lhs +false +//- operator +||= +//- rhs +true +//- result +true diff --git a/src/compound-assignment-private/rshift.case b/src/compound-assignment-private/rshift.case new file mode 100644 index 0000000000..67ad7d1dde --- /dev/null +++ b/src/compound-assignment-private/rshift.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound right-shift assignment with target being a private reference +---*/ + +//- lhs +0b1100 +//- operator +>>>= +//- rhs +2 +//- result +0b0011 diff --git a/src/compound-assignment-private/srshift.case b/src/compound-assignment-private/srshift.case new file mode 100644 index 0000000000..c1bcd25024 --- /dev/null +++ b/src/compound-assignment-private/srshift.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound signed-right-shift assignment with target being a private reference +---*/ + +//- lhs +0b1100 +//- operator +>>= +//- rhs +2 +//- result +0b0011 diff --git a/src/compound-assignment-private/sub.case b/src/compound-assignment-private/sub.case new file mode 100644 index 0000000000..9dc7f1be96 --- /dev/null +++ b/src/compound-assignment-private/sub.case @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +template: default +desc: Compound subtraction assignment with target being a private reference +---*/ + +//- lhs +3 +//- operator +-= +//- rhs +2 +//- result +1 diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-add.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-add.js new file mode 100644 index 0000000000..46903a0592 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-add.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/add.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound addition assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 1; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field += 2; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 3, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 3, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-and.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-and.js new file mode 100644 index 0000000000..78dadeef59 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-and.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/and.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound logical-and assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return true; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field &&= false; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), false, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), false, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitand.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitand.js new file mode 100644 index 0000000000..37ce12e148 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitand.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitand.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound bitwise-and assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 0b0101; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field &= 0b1010; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0b0000, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 0b0000, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitor.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitor.js new file mode 100644 index 0000000000..fe3f705023 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitor.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitor.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound bitwise-or assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 0b0101; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field |= 0b1010; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0b1111, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 0b1111, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitxor.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitxor.js new file mode 100644 index 0000000000..768616bfad --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-bitxor.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitxor.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound bitwise-xor assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 0x1111; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field ^= 0x1010; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0x0101, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 0x0101, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-div.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-div.js new file mode 100644 index 0000000000..42ee151b16 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-div.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/div.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound division assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 1; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field /= 2; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0.5, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 0.5, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-exp.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-exp.js new file mode 100644 index 0000000000..9648139596 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-exp.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/exp.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound exponentiation assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 10; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field **= 3; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 1000, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 1000, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-lshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-lshift.js new file mode 100644 index 0000000000..13da292f79 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-lshift.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/lshift.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound left-shift assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 0b0110; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field <<= 4; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0b01100000, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 0b01100000, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-mod.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-mod.js new file mode 100644 index 0000000000..cc0598fc3f --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-mod.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/mod.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound modulo assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 3; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field %= 2; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 1, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 1, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-mult.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-mult.js new file mode 100644 index 0000000000..10be59dada --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-mult.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/mult.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound multiplication assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 2; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field *= 3; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 6, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 6, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-nullish.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-nullish.js new file mode 100644 index 0000000000..44aad7afe6 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-nullish.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/nullish.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound nullish-coalescing assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return null; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field ??= 1; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 1, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 1, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-or.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-or.js new file mode 100644 index 0000000000..8d4c7c61e1 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-or.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/or.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound logical-or assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return false; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field ||= true; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), true, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), true, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-rshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-rshift.js new file mode 100644 index 0000000000..1917c2724d --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-rshift.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/rshift.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound right-shift assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 0b1100; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field >>>= 2; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0b0011, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 0b0011, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-srshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-srshift.js new file mode 100644 index 0000000000..cd22d1a779 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-srshift.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/srshift.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound signed-right-shift assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 0b1100; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field >>= 2; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0b0011, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 0b0011, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-sub.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-sub.js new file mode 100644 index 0000000000..a1b6b5802a --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-accessor-property-sub.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/sub.case +// - src/compound-assignment-private/default/getter-setter.template +/*--- +description: Compound subtraction assignment with target being a private reference (to an accessor property with getter and setter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + ... + 5.c. Let _setter_ be _entry_.[[Set]]. + d. Perform ? Call(_setter_, _O_, « _value_ »). + +---*/ + + +class C { + #setterCalledWith; + get #field() { + return 3; + } + set #field(value) { + this.#setterCalledWith = value; + } + compoundAssignment() { + return this.#field -= 2; + } + setterCalledWithValue() { + return this.#setterCalledWith; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 1, "The expression should evaluate to the result"); +assert.sameValue(o.setterCalledWithValue(), 1, "PutValue should call the setter with the result"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-add.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-add.js new file mode 100644 index 0000000000..8eeeba9432 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-add.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/add.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound addition assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 1; + compoundAssignment() { + return this.#field += 2; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 3, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 3, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-and.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-and.js new file mode 100644 index 0000000000..5208a2d3c0 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-and.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/and.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound logical-and assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = true; + compoundAssignment() { + return this.#field &&= false; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), false, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), false, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitand.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitand.js new file mode 100644 index 0000000000..608d861c62 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitand.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitand.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound bitwise-and assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 0b0101; + compoundAssignment() { + return this.#field &= 0b1010; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0b0000, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 0b0000, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitor.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitor.js new file mode 100644 index 0000000000..32489830d4 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitor.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitor.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound bitwise-or assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 0b0101; + compoundAssignment() { + return this.#field |= 0b1010; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0b1111, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 0b1111, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitxor.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitxor.js new file mode 100644 index 0000000000..9e9c028d7e --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-bitxor.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitxor.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound bitwise-xor assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 0x1111; + compoundAssignment() { + return this.#field ^= 0x1010; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0x0101, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 0x0101, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-div.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-div.js new file mode 100644 index 0000000000..fb4de3dded --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-div.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/div.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound division assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 1; + compoundAssignment() { + return this.#field /= 2; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0.5, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 0.5, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-exp.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-exp.js new file mode 100644 index 0000000000..e62385acfb --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-exp.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/exp.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound exponentiation assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 10; + compoundAssignment() { + return this.#field **= 3; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 1000, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 1000, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-lshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-lshift.js new file mode 100644 index 0000000000..1b9a933056 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-lshift.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/lshift.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound left-shift assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 0b0110; + compoundAssignment() { + return this.#field <<= 4; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0b01100000, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 0b01100000, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-mod.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-mod.js new file mode 100644 index 0000000000..f48335019b --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-mod.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/mod.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound modulo assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 3; + compoundAssignment() { + return this.#field %= 2; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 1, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 1, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-mult.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-mult.js new file mode 100644 index 0000000000..486b9d567d --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-mult.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/mult.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound multiplication assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 2; + compoundAssignment() { + return this.#field *= 3; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 6, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 6, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-nullish.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-nullish.js new file mode 100644 index 0000000000..e8ecb5f6dd --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-nullish.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/nullish.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound nullish-coalescing assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = null; + compoundAssignment() { + return this.#field ??= 1; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 1, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 1, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-or.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-or.js new file mode 100644 index 0000000000..1057c97e80 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-or.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/or.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound logical-or assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = false; + compoundAssignment() { + return this.#field ||= true; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), true, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), true, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-rshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-rshift.js new file mode 100644 index 0000000000..f76d530b47 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-rshift.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/rshift.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound right-shift assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 0b1100; + compoundAssignment() { + return this.#field >>>= 2; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0b0011, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 0b0011, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-srshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-srshift.js new file mode 100644 index 0000000000..87ce6e3b7d --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-srshift.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/srshift.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound signed-right-shift assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 0b1100; + compoundAssignment() { + return this.#field >>= 2; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 0b0011, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 0b0011, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-sub.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-sub.js new file mode 100644 index 0000000000..4676f0ea6b --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-data-property-sub.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/sub.case +// - src/compound-assignment-private/default/data-property.template +/*--- +description: Compound subtraction assignment with target being a private reference (to a field) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 3. If _entry_.[[Kind]] is ~field~, then + a. Set _entry_.[[Value]] to _value_. + +---*/ + + +class C { + #field = 3; + compoundAssignment() { + return this.#field -= 2; + } + fieldValue() { + return this.#field; + } +} + +const o = new C(); +assert.sameValue(o.compoundAssignment(), 1, "The expression should evaluate to the result"); +assert.sameValue(o.fieldValue(), 1, "PutValue should store the result in the private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-add.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-add.js new file mode 100644 index 0000000000..29d1ad6557 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-add.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/add.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound addition assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod += 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-and.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-and.js new file mode 100644 index 0000000000..2d7d44a973 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-and.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/and.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound logical-and assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod &&= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitand.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitand.js new file mode 100644 index 0000000000..b2aa8286ee --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitand.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitand.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound bitwise-and assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod &= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitor.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitor.js new file mode 100644 index 0000000000..e55d768633 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitor.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitor.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound bitwise-or assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod |= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitxor.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitxor.js new file mode 100644 index 0000000000..5f9f6d86f6 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-bitxor.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitxor.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound bitwise-xor assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod ^= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-div.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-div.js new file mode 100644 index 0000000000..b5de4f34a9 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-div.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/div.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound division assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod /= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-exp.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-exp.js new file mode 100644 index 0000000000..25036c1d86 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-exp.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/exp.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound exponentiation assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod **= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-lshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-lshift.js new file mode 100644 index 0000000000..e9016f55dd --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-lshift.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/lshift.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound left-shift assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod <<= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-mod.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-mod.js new file mode 100644 index 0000000000..a9b5438889 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-mod.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/mod.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound modulo assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod %= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-mult.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-mult.js new file mode 100644 index 0000000000..8c69d15e24 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-mult.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/mult.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound multiplication assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod *= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-nullish.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-nullish.js new file mode 100644 index 0000000000..9d1ad3243d --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-nullish.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/nullish.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound nullish-coalescing assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod ??= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-or.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-or.js new file mode 100644 index 0000000000..1ff03b32a2 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-or.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/or.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound logical-or assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod ||= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-rshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-rshift.js new file mode 100644 index 0000000000..87f7d62bdc --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-rshift.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/rshift.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound right-shift assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod >>>= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-srshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-srshift.js new file mode 100644 index 0000000000..e6aa21b6a9 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-srshift.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/srshift.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound signed-right-shift assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod >>= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-sub.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-sub.js new file mode 100644 index 0000000000..cd847060b9 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-method-sub.js @@ -0,0 +1,48 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/sub.case +// - src/compound-assignment-private/default/method.template +/*--- +description: Compound subtraction assignment with target being a private reference (to a private method) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 4. Else if _entry_.[[Kind]] is ~method~, then + a. Throw a *TypeError* exception. + +---*/ + + +class C { + #privateMethod() {} + compoundAssignment() { + return this.#privateMethod -= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result in a method private reference"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-add.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-add.js new file mode 100644 index 0000000000..50f564a981 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-add.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/add.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound addition assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field += 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-and.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-and.js new file mode 100644 index 0000000000..920814199d --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-and.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/and.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound logical-and assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field &&= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitand.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitand.js new file mode 100644 index 0000000000..28f9cf0a94 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitand.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitand.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound bitwise-and assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field &= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitor.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitor.js new file mode 100644 index 0000000000..79b320074c --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitor.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitor.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound bitwise-or assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field |= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitxor.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitxor.js new file mode 100644 index 0000000000..95070449e6 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-bitxor.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/bitxor.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound bitwise-xor assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field ^= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-div.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-div.js new file mode 100644 index 0000000000..9de9083e98 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-div.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/div.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound division assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field /= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-exp.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-exp.js new file mode 100644 index 0000000000..b0e17bb8e7 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-exp.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/exp.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound exponentiation assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field **= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-lshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-lshift.js new file mode 100644 index 0000000000..47711064f2 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-lshift.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/lshift.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound left-shift assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field <<= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-mod.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-mod.js new file mode 100644 index 0000000000..973e087f8c --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-mod.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/mod.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound modulo assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field %= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-mult.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-mult.js new file mode 100644 index 0000000000..0d3a601a54 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-mult.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/mult.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound multiplication assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field *= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-nullish.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-nullish.js new file mode 100644 index 0000000000..4b64e52fd5 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-nullish.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/nullish.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound nullish-coalescing assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field ??= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-or.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-or.js new file mode 100644 index 0000000000..3e0c16123e --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-or.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/or.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound logical-or assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field ||= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-rshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-rshift.js new file mode 100644 index 0000000000..a6e9a90812 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-rshift.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/rshift.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound right-shift assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field >>>= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-srshift.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-srshift.js new file mode 100644 index 0000000000..3ce79d3a0b --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-srshift.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/srshift.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound signed-right-shift assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field >>= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter"); diff --git a/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-sub.js b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-sub.js new file mode 100644 index 0000000000..6ed9f7f252 --- /dev/null +++ b/test/language/expressions/compound-assignment/left-hand-side-private-reference-readonly-accessor-property-sub.js @@ -0,0 +1,50 @@ +// This file was procedurally generated from the following sources: +// - src/compound-assignment-private/sub.case +// - src/compound-assignment-private/default/getter.template +/*--- +description: Compound subtraction assignment with target being a private reference (to an accessor property with getter) +esid: sec-assignment-operators-runtime-semantics-evaluation +features: [class-fields-private] +flags: [generated] +info: | + sec-assignment-operators-runtime-semantics-evaluation + AssignmentExpression : LeftHandSideExpression AssignmentOperator AssignmentExpression + 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. + 2. Let _lval_ be ? GetValue(_lref_). + ... + 7. Let _r_ be ApplyStringOrNumericBinaryOperator(_lval_, _opText_, _rval_). + 8. Perform ? PutValue(_lref_, _r_). + 9. Return _r_. + + sec-property-accessors-runtime-semantics-evaluation + MemberExpression : MemberExpression `.` PrivateIdentifier + + 1. Let _baseReference_ be the result of evaluating |MemberExpression|. + 2. Let _baseValue_ be ? GetValue(_baseReference_). + 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. + 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). + + PutValue (V, W) + ... + 5.b. If IsPrivateReference(_V_) is *true*, then + i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). + + PrivateSet (O, P, value) + ... + 5.a. Assert: _entry_.[[Kind]] is ~accessor~. + b. If _entry_.[[Set]] is *undefined*, throw a *TypeError* exception. + +---*/ + + +class C { + get #field() { + return 1; + } + compoundAssignment() { + return this.#field -= 1; + } +} + +const o = new C(); +assert.throws(TypeError, () => o.compoundAssignment(), "PutValue throws when storing the result if no setter");