Debian Codegraph @

js/src/tests/test262/language/expressions/async-arrow-function/unscopables-with.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/function-forms/unscopables-with.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 count++;
67 with (globalThis) {
68 count++;
69 assert.sameValue(v, undefined, 'The value of `v` is expected to equal `undefined`');
70 }
71 count++;
72 var v = x;
73 with (globalThis) {
74 count++;
75 assert.sameValue(v, 10, 'The value of `v` is 10');
76 v = 20;
77 }
78 assert.sameValue(v, 20, 'The value of `v` is 20');
79 assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
80 callCount = callCount + 1;
81 };
82
83 ref(10).then(() => {
84 assert.sameValue(callCount, 1, 'async arrow function invoked exactly once')
85 }).then($DONE, $DONE);
86
87 count++;
88 }
89 assert.sameValue(count, 6, 'The value of `count` is 6');