Debian Codegraph @

js/src/tests/test262/language/expressions/async-arrow-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-arrow-function.template
5 /*---
6 description: Symbol.unscopables behavior across scope boundaries (async arrow function expression)
7 esid: sec-async-arrow-function-definitions
8 features: [globalThis, Symbol.unscopables, async-functions]
9 flags: [generated, noStrict, async]
10 info: |
11 14.7 Async Arrow Function Definitions
12
13 AsyncArrowFunction :
14 ...
15 CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody
16
17 AsyncConciseBody :
18 { AsyncFunctionBody }
19
20 ...
21
22 Supplemental Syntax
23
24 When processing an instance of the production AsyncArrowFunction :
25 CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody the interpretation of
26 CoverCallExpressionAndAsyncArrowHead is refined using the following grammar:
27
28 AsyncArrowHead :
29 async ArrowFormalParameters
30
31
32 ...
33 Let envRec be lex's EnvironmentRecord.
34 Let exists be ? envRec.HasBinding(name).
35
36 HasBinding
37
38 ...
39 If the withEnvironment flag of envRec is false, return true.
40 Let unscopables be ? Get(bindings, @@unscopables).
41 If Type(unscopables) is Object, then
42 Let blocked be ToBoolean(? Get(unscopables, N)).
43 If blocked is true, return false.
44
45 (The `with` Statement) Runtime Semantics: Evaluation
46
47 ...
48 Set the withEnvironment flag of newEnv’s EnvironmentRecord to true.
49 ...
50
51 ---*/
52 let count = 0;
53 var v = 1;
54 globalThis[Symbol.unscopables] = {
55 v: true,
56 };
57
58 {
59 count++;
60
61
62 var callCount = 0;
63
64 // Stores a reference `ref` for case evaluation
65 var ref = async (x) => {
66 (function() {
67 count++;
68 with (globalThis) {
69 count++;
70 assert.sameValue(v, 1, 'The value of `v` is 1');
71 }
72 })();
73 (function() {
74 count++;
75 var v = x;
76 with (globalThis) {
77 count++;
78 assert.sameValue(v, 10, 'The value of `v` is 10');
79 v = 20;
80 }
81 assert.sameValue(v, 20, 'The value of `v` is 20');
82 assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
83 })();
84 assert.sameValue(v, 1, 'The value of `v` is 1');
85 assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
86 callCount = callCount + 1;
87 };
88
89 ref(10).then(() => {
90 assert.sameValue(callCount, 1, 'async arrow function invoked exactly once')
91 }).then($DONE, $DONE);
92
93 count++;
94 }
95 assert.sameValue(count, 6, 'The value of `count` is 6');