Debian Codegraph @

js/src/tests/test262/language/statements/with/get-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-getbindingvalue-n-s
6 description: >
7 Binding deleted when retrieving unscopables.
8 info: |
9 9.1.1.2.6 GetBindingValue ( N, S )
10
11 1. Let bindingObject be envRec.[[BindingObject]].
12 2. Let value be ? HasProperty(bindingObject, N).
13 3. If value is false, then
14 a. If S is false, return undefined; otherwise throw a ReferenceError exception.
15 ...
16
17 flags: [noStrict]
18 features: [Symbol.unscopables]
19 ---*/
20
21 var unscopablesCalled = 0;
22
23 var env = {
24 binding: 0,
25 get [Symbol.unscopables]() {
26 unscopablesCalled++;
27 delete env.binding;
28 return null;
29 }
30 };
31
32 var result = null;
33 with (env) {
34 result = binding;
35 }
36
37 assert.sameValue(unscopablesCalled, 1, "get [Symbol.unscopables] called once");
38
39 assert.sameValue(result, undefined, "result set to undefined");
40
41 reportCompare(0, 0);