Debian Codegraph @

js/src/tests/test262/language/statements/with/set-mutable-binding-binding-deleted-in-get-unscopables.js

raw
1 // Copyright (C) 2024 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-object-environment-records-setmutablebinding-n-v-s
6 description: >
7 Binding deleted when retrieving unscopables.
8 info: |
9 9.1.1.2.5 SetMutableBinding ( N, V, S )
10
11 1. Let bindingObject be envRec.[[BindingObject]].
12 2. Let stillExists be ? HasProperty(bindingObject, N).
13 3. If stillExists is false and S is true, throw a ReferenceError exception.
14 4. Perform ? Set(bindingObject, N, V, S).
15 ...
16
17 flags: [noStrict]
18 features: [Symbol.unscopables]
19 includes: [propertyHelper.js]
20 ---*/
21
22 var unscopablesCalled = 0;
23
24 var env = {
25 binding: 0,
26 get [Symbol.unscopables]() {
27 unscopablesCalled++;
28 delete env.binding;
29 return null;
30 }
31 };
32
33 with (env) {
34 binding = 123;
35 }
36
37 assert.sameValue(unscopablesCalled, 1, "get [Symbol.unscopables] called once");
38
39 verifyProperty(env, "binding", {
40 value: 123,
41 writable: true,
42 enumerable: true,
43 configurable: true,
44 });
45
46 reportCompare(0, 0);