Debian Codegraph @

js/src/tests/test262/language/statements/async-function/unscopables-with-in-nested-fn.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/function-forms/unscopables-with-in-nested-fn.case
4 // - src/function-forms/default/async-func-decl.template
5 /*---
6 description: Symbol.unscopables behavior across scope boundaries (async function declaration)
7 esid: sec-async-function-definitions
8 features: [globalThis, Symbol.unscopables, async-functions]
9 flags: [generated, noStrict, async]
10 info: |
11 14.6 Async Function Definitions
12
13 AsyncFunctionDeclaration :
14 async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
15
16
17 ...
18 Let envRec be lex's EnvironmentRecord.
19 Let exists be ? envRec.HasBinding(name).
20
21 HasBinding
22
23 ...
24 If the withEnvironment flag of envRec is false, return true.
25 Let unscopables be ? Get(bindings, @@unscopables).
26 If Type(unscopables) is Object, then
27 Let blocked be ToBoolean(? Get(unscopables, N)).
28 If blocked is true, return false.
29
30 (The `with` Statement) Runtime Semantics: Evaluation
31
32 ...
33 Set the withEnvironment flag of newEnv’s EnvironmentRecord to true.
34 ...
35
36 ---*/
37 let count = 0;
38 var v = 1;
39 globalThis[Symbol.unscopables] = {
40 v: true,
41 };
42
43 {
44 count++;
45
46
47 var callCount = 0;
48
49 // Stores a reference `ref` for case evaluation
50 async function ref(x) {
51 (function() {
52 count++;
53 with (globalThis) {
54 count++;
55 assert.sameValue(v, 1, 'The value of `v` is 1');
56 }
57 })();
58 (function() {
59 count++;
60 var v = x;
61 with (globalThis) {
62 count++;
63 assert.sameValue(v, 10, 'The value of `v` is 10');
64 v = 20;
65 }
66 assert.sameValue(v, 20, 'The value of `v` is 20');
67 assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
68 })();
69 assert.sameValue(v, 1, 'The value of `v` is 1');
70 assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
71 callCount = callCount + 1;
72 }
73
74 ref(10).then(() => {
75 assert.sameValue(callCount, 1, 'function invoked exactly once');
76 }).then($DONE, $DONE);
77
78 count++;
79 }
80 assert.sameValue(count, 6, 'The value of `count` is 6');