Debian Codegraph @

rhino/testsrc/tests/js1_5/Scope/regress-202678-001.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-001.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 }
43
44
45 function insideFunc()
46 {
47 actual = hidden;
48 }
49 }
50
51
52
53 status = inSection(1);
54 myFunc(); // this sets |actual|
55 expect = 'aaa';
56 addThis();
57
58 status = inSection(2);
59 outSideFunc(); // sets |actual|
60 expect = 'bbb';
61 addThis();
62
63 status = inSection(3);
64 myFunc(); // sets |actual|
65 expect = 'aaa';
66 addThis();
67
68 status = inSection(4);
69 outSideFunc(); // sets |actual|
70 expect = 'bbb'; // NOT 'ccc'
71 addThis();
72
73
74
75
76 //-----------------------------------------------------------------------------
77 test();
78 //-----------------------------------------------------------------------------
79
80
81
82 function addThis()
83 {
84 statusitems[UBound] = status;
85 actualvalues[UBound] = actual;
86 expectedvalues[UBound] = expect;
87 UBound++;
88 }
89
90
91 function test()
92 {
93 enterFunc('test');
94 printBugNumber(BUGNUMBER);
95 printStatus(summary);
96
97 for (var i=0; i<UBound; i++)
98 {
99 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
100 }
101
102 exitFunc ('test');
103 }