regress-220362.js (1601B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 /* 7 * 8 * Date: 27 Sep 2003 9 * SUMMARY: Calling a local function from global scope 10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=220362 11 * 12 */ 13 //----------------------------------------------------------------------------- 14 var UBound = 0; 15 var BUGNUMBER = 220362; 16 var summary = 'Calling a local function from global scope'; 17 var status = ''; 18 var statusitems = []; 19 var actual = ''; 20 var actualvalues = []; 21 var expect= ''; 22 var expectedvalues = []; 23 24 25 // creates a local function and calls it immediately 26 function a() 27 { 28 var x = 'A'; 29 var f = function() {return x;}; 30 return f(); 31 } 32 33 // creates and returns a local function 34 function b() 35 { 36 var x = 'B'; 37 var f = function() {return x;}; 38 return f; 39 } 40 41 42 status = inSection(1); 43 actual = a(); 44 expect = 'A'; 45 addThis(); 46 47 status = inSection(2); 48 var f = b(); 49 actual = f(); 50 expect = 'B'; 51 addThis(); 52 53 54 55 //----------------------------------------------------------------------------- 56 test(); 57 //----------------------------------------------------------------------------- 58 59 60 61 function addThis() 62 { 63 statusitems[UBound] = status; 64 actualvalues[UBound] = actual; 65 expectedvalues[UBound] = expect; 66 UBound++; 67 } 68 69 70 function test() 71 { 72 printBugNumber(BUGNUMBER); 73 printStatus(summary); 74 75 for (var i=0; i<UBound; i++) 76 { 77 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 78 } 79 }