js/src/tests/js1_5/Scope/regress-202678-002.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:6deaeece11c8
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 UBound = 0;
16 var BUGNUMBER = 202678;
17 var summary = 'Testing nested function scope capture';
18 var status = '';
19 var statusitems = [];
20 var actual = '';
21 var actualvalues = [];
22 var expect= '';
23 var expectedvalues = [];
24 var self = this;
25
26
27 function myFunc()
28 {
29 var hidden = 'aaa';
30 insideFunc();
31
32 if (!self.runOnce)
33 {
34 var hidden = 'bbb';
35 self.outSideFunc = insideFunc;
36 self.runOnce = true;
37 }
38 else
39 {
40 var hidden = 'ccc';
41 self.outSideFunc = insideFunc;
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 = '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 }

mercurial