lgcl-nullish-assignment-operator-bigint.js (932B)
1 // Copyright (c) 2020 Ecma International. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-assignment-operators-runtime-semantics-evaluation 6 description: Logical Nullish Assignment Operator 7 features: [BigInt, logical-assignment-operators] 8 info: | 9 AssignmentExpression: 10 LeftHandSideExpression ??= AssignmentExpression 11 12 1. Let lref be the result of evaluating LeftHandSideExpression. 13 2. Let lval be ? GetValue(lref). 14 3. If lval is neither undefined nor null, return lval. 15 4. Let rref be the result of evaluating AssignmentExpression. 16 5. Let rval be ? GetValue(rref). 17 6. Perform ? PutValue(lref, rval). 18 7. Return rval. 19 20 ---*/ 21 22 var value = 0n; 23 assert.sameValue(value ??= 1n, 0n, "(value ??= 1n) === 0n; where value = 0n"); 24 25 value = 2n; 26 assert.sameValue(value ??= 1n, 2n, "(value ??= 1n) === 2n; where value = 2n"); 27 28 reportCompare(0, 0);