nameless-unscopables-with-in-nested-fn.js (2095B)
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-expr-nameless.template 5 /*--- 6 description: Symbol.unscopables behavior across scope boundaries (async function nameless expression) 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 AsyncFunctionExpression : 14 async function ( 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 var ref; 51 ref = async function(x) { 52 (function() { 53 count++; 54 with (globalThis) { 55 count++; 56 assert.sameValue(v, 1, 'The value of `v` is 1'); 57 } 58 })(); 59 (function() { 60 count++; 61 var v = x; 62 with (globalThis) { 63 count++; 64 assert.sameValue(v, 10, 'The value of `v` is 10'); 65 v = 20; 66 } 67 assert.sameValue(v, 20, 'The value of `v` is 20'); 68 assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); 69 })(); 70 assert.sameValue(v, 1, 'The value of `v` is 1'); 71 assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1'); 72 callCount = callCount + 1; 73 }; 74 75 ref(10).then(() => { 76 assert.sameValue(callCount, 1, 'function invoked exactly once'); 77 }).then($DONE, $DONE); 78 79 count++; 80 } 81 assert.sameValue(count, 6, 'The value of `count` is 6');