diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/statements/with/unscopables-inc-dec.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/statements/with/unscopables-inc-dec.js')
-rw-r--r-- | js/src/tests/test262/language/statements/with/unscopables-inc-dec.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/with/unscopables-inc-dec.js b/js/src/tests/test262/language/statements/with/unscopables-inc-dec.js new file mode 100644 index 0000000000..bad2ecd079 --- /dev/null +++ b/js/src/tests/test262/language/statements/with/unscopables-inc-dec.js @@ -0,0 +1,53 @@ +// Copyright (C) 2017 Mozilla Corporation. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object-environment-records-hasbinding-n +description: > + @@unscopables should be looked up exactly once for inc/dec. +info: | + UpdateExpression : LeftHandSideExpression ++ + 1. Let lhs be the result of evaluating LeftHandSideExpression. + + GetIdentifierReference ( lex, name, strict ) + [...] + 3. Let exists be ? envRec.HasBinding(name). + + HasBinding ( N ) + [...] + 6. Let unscopables be ? Get(bindings, @@unscopables). +flags: [noStrict] +features: [Symbol.unscopables] +---*/ + +var unscopablesGetterCalled = 0; +var a, b, flag = true; +with (a = { x: 7 }) { + with (b = { x: 4, get [Symbol.unscopables]() { + unscopablesGetterCalled++; + return { x: flag=!flag }; + } }) { + x++; + } +} + +assert.sameValue(unscopablesGetterCalled, 1); +assert.sameValue(a.x, 7); +assert.sameValue(b.x, 5); + +unscopablesGetterCalled = 0; +flag = true; +with (a = { x: 7 }) { + with (b = { x: 4, get [Symbol.unscopables]() { + unscopablesGetterCalled++; + return { x: flag=!flag }; + } }) { + x--; + } +} + +assert.sameValue(unscopablesGetterCalled, 1); +assert.sameValue(a.x, 7); +assert.sameValue(b.x, 3); + +reportCompare(0, 0); |