Debian Codegraph @

js/src/tests/test262/language/expressions/async-generator/named-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-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 count++;
55 with (globalThis) {
56 count++;
57 assert.sameValue(v, undefined, 'The value of `v` is expected to equal `undefined`');
58 }
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 callCount = callCount + 1;
69 };
70
71 ref(10).next().then(() => {
72 assert.sameValue(callCount, 1, 'generator function invoked exactly once');
73 }).then($DONE, $DONE);
74
75 count++;
76 }
77 assert.sameValue(count, 6, 'The value of `count` is 6');