Debian Codegraph @

rhino/testsrc/tests/js1_5/Scope/regress-202678-002.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: 19 April 2003
9 * SUMMARY: Testing nested function scope capture
10 *
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=202678
12 *
13 */
14 //-----------------------------------------------------------------------------
15 var gTestfile = 'regress-202678-002.js';
16 var UBound = 0;
17 var BUGNUMBER = 202678;
18 var summary = 'Testing nested function scope capture';
19 var status = '';
20 var statusitems = [];
21 var actual = '';
22 var actualvalues = [];
23 var expect= '';
24 var expectedvalues = [];
25 var self = this;
26
27
28 function myFunc()
29 {
30 var hidden = 'aaa';
31 insideFunc();
32
33 if (!self.runOnce)
34 {
35 var hidden = 'bbb';
36 self.outSideFunc = insideFunc;
37 self.runOnce = true;
38 }
39 else
40 {
41 var hidden = 'ccc';
42 self.outSideFunc = insideFunc;
43 }
44
45
46 function insideFunc()
47 {
48 actual = hidden;
49 }
50 }
51
52
53
54 status = inSection(1);
55 myFunc(); // this sets |actual|
56 expect = 'aaa';
57 addThis();
58
59 status = inSection(2);
60 outSideFunc(); // sets |actual|
61 expect = 'bbb';
62 addThis();
63
64 status = inSection(3);
65 myFunc(); // sets |actual|
66 expect = 'aaa';
67 addThis();
68
69 status = inSection(4);
70 outSideFunc(); // sets |actual|
71 expect = 'ccc';
72 addThis();
73
74
75
76
77 //-----------------------------------------------------------------------------
78 test();
79 //-----------------------------------------------------------------------------
80
81
82
83 function addThis()
84 {
85 statusitems[UBound] = status;
86 actualvalues[UBound] = actual;
87 expectedvalues[UBound] = expect;
88 UBound++;
89 }
90
91
92 function test()
93 {
94 enterFunc('test');
95 printBugNumber(BUGNUMBER);
96 printStatus(summary);
97
98 for (var i=0; i<UBound; i++)
99 {
100 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
101 }
102
103 exitFunc ('test');
104 }