js/src/tests/test262/language/expressions/logical-assignment/left-hand-side-private-reference-data-property-short-circuit-or.js
raw symbols SCIP| 1 | // This file was procedurally generated from the following sources: |
| 2 | // - src/logical-assignment-private/or.case |
| 3 | // - src/logical-assignment-private/default/data-property-short-circuit.template |
| 4 | /*--- |
| 5 | description: Logical-or assignment with target being a private reference (to a field (short-circuit version)) |
| 6 | esid: sec-assignment-operators-runtime-semantics-evaluation |
| 7 | features: [class-fields-private, logical-assignment-operators] |
| 8 | flags: [generated] |
| 9 | info: | |
| 10 | sec-property-accessors-runtime-semantics-evaluation |
| 11 | MemberExpression : MemberExpression `.` PrivateIdentifier |
| 12 | |
| 13 | 1. Let _baseReference_ be the result of evaluating |MemberExpression|. |
| 14 | 2. Let _baseValue_ be ? GetValue(_baseReference_). |
| 15 | 3. Let _fieldNameString_ be the StringValue of |PrivateIdentifier|. |
| 16 | 4. Return ! MakePrivateReference(_baseValue_, _fieldNameString_). |
| 17 | |
| 18 | PutValue (V, W) |
| 19 | ... |
| 20 | 5.b. If IsPrivateReference(_V_) is *true*, then |
| 21 | i. Return ? PrivateSet(_baseObj_, _V_.[[ReferencedName]], _W_). |
| 22 | |
| 23 | PrivateSet (O, P, value) |
| 24 | ... |
| 25 | 3. If _entry_.[[Kind]] is ~field~, then |
| 26 | a. Set _entry_.[[Value]] to _value_. |
| 27 | |
| 28 | |
| 29 | sec-assignment-operators-runtime-semantics-evaluation |
| 30 | AssignmentExpression : LeftHandSideExpression ||= AssignmentExpression |
| 31 | 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|. |
| 32 | 2. Let _lval_ be ? GetValue(_lref_). |
| 33 | 3. Let _lbool_ be ! ToBoolean(_lval_). |
| 34 | 4. If _lbool_ is *true*, return _lval_. |
| 35 | ... |
| 36 | 7. Perform ? PutValue(_lref_, _rval_). |
| 37 | 8. Return _rval_. |
| 38 | ---*/ |
| 39 | |
| 40 | |
| 41 | function doNotCall() { |
| 42 | throw new Test262Error("The right-hand side should not be evaluated"); |
| 43 | } |
| 44 | |
| 45 | class C { |
| 46 | #field = true; |
| 47 | compoundAssignment() { |
| 48 | return this.#field ||= doNotCall(); |
| 49 | } |
| 50 | fieldValue() { |
| 51 | return this.#field; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | const o = new C(); |
| 56 | assert.sameValue(o.compoundAssignment(), true, "The expression should evaluate to the short-circuit value"); |
| 57 | |
| 58 | reportCompare(0, 0); |