scope-var-close.js (914B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-prepareforordinarycall 5 description: > 6 Removal of variable environment for the function parameters and body 7 info: | 8 [...] 9 3. Let callerContext be the running execution context. 10 [...] 11 8. Remove calleeContext from the execution context stack and restore 12 callerContext as the running execution context. 13 [...] 14 ---*/ 15 16 var probe; 17 18 // This test intentionally elides parameter expressions because their presence 19 // triggers the creation of an additional LexicalEnvironment dedicated to the 20 // function body (see sec-functiondeclarationinstantiation) 21 (function() { 22 var x = 'inside'; 23 probe = function() { return x; }; 24 }()); 25 26 var x = 'outside'; 27 28 assert.sameValue(probe(), 'inside'); 29 assert.sameValue(x, 'outside'); 30 31 reportCompare(0, 0);