Debian Codegraph @

rhino/testsrc/tests/js1_5/Scope/regress-220362.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 gTestfile = 'regress-220362.js';
15 var UBound = 0;
16 var BUGNUMBER = 220362;
17 var summary = 'Calling a local function from global scope';
18 var status = '';
19 var statusitems = [];
20 var actual = '';
21 var actualvalues = [];
22 var expect= '';
23 var expectedvalues = [];
24
25
26 // creates a local function and calls it immediately
27 function a()
28 {
29 var x = 'A';
30 var f = function() {return x;};
31 return f();
32 }
33
34 // creates and returns a local function
35 function b()
36 {
37 var x = 'B';
38 var f = function() {return x;};
39 return f;
40 }
41
42
43 status = inSection(1);
44 actual = a();
45 expect = 'A';
46 addThis();
47
48 status = inSection(2);
49 var f = b();
50 actual = f();
51 expect = 'B';
52 addThis();
53
54
55
56 //-----------------------------------------------------------------------------
57 test();
58 //-----------------------------------------------------------------------------
59
60
61
62 function addThis()
63 {
64 statusitems[UBound] = status;
65 actualvalues[UBound] = actual;
66 expectedvalues[UBound] = expect;
67 UBound++;
68 }
69
70
71 function test()
72 {
73 enterFunc('test');
74 printBugNumber(BUGNUMBER);
75 printStatus(summary);
76
77 for (var i=0; i<UBound; i++)
78 {
79 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
80 }
81
82 exitFunc ('test');
83 }