Debian Codegraph @

js/src/tests/test262/language/expressions/async-generator/named-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-gen-named-func-expr.template
5 /*---
6 description: Symbol.unscopables behavior across scope boundaries (async generator named function expression)
7 esid: sec-asyncgenerator-definitions-evaluation
8 features: [globalThis, Symbol.unscopables, async-iteration]
9 flags: [generated, noStrict, async]
10 info: |
11 AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier
12 ( FormalParameters ) { AsyncGeneratorBody }
13
14 [...]
15 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters,
16 AsyncGeneratorBody, funcEnv, strict).
17 [...]
18
19
20 ...
21 Let envRec be lex's EnvironmentRecord.
22 Let exists be ? envRec.HasBinding(name).
23
24 HasBinding
25
26 ...
27 If the withEnvironment flag of envRec is false, return true.
28 Let unscopables be ? Get(bindings, @@unscopables).
29 If Type(unscopables) is Object, then
30 Let blocked be ToBoolean(? Get(unscopables, N)).
31 If blocked is true, return false.
32
33 (The `with` Statement) Runtime Semantics: Evaluation
34
35 ...
36 Set the withEnvironment flag of newEnv’s EnvironmentRecord to true.
37 ...
38
39 ---*/
40 let count = 0;
41 var v = 1;
42 globalThis[Symbol.unscopables] = {
43 v: true,
44 };
45
46 {
47 count++;
48
49
50 var callCount = 0;
51 // Stores a reference `ref` for case evaluation
52 var ref;
53 ref = async function* g(x) {
54 (function() {
55 count++;
56 with (globalThis) {
57 count++;
58 assert.sameValue(v, 1, 'The value of `v` is 1');
59 }
60 })();
61 (function() {
62 count++;
63 var v = x;
64 with (globalThis) {
65 count++;
66 assert.sameValue(v, 10, 'The value of `v` is 10');
67 v = 20;
68 }
69 assert.sameValue(v, 20, 'The value of `v` is 20');
70 assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
71 })();
72 assert.sameValue(v, 1, 'The value of `v` is 1');
73 assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
74 callCount = callCount + 1;
75 };
76
77 ref(10).next().then(() => {
78 assert.sameValue(callCount, 1, 'generator function invoked exactly once');
79 }).then($DONE, $DONE);
80
81 count++;
82 }
83 assert.sameValue(count, 6, 'The value of `count` is 6');