blob: 64938225a6b1244501ce4ee4f0d7708cf6d7937e [file] [log] [blame]
darincd553de2003-10-13 02:05:37 +00001/*
2* The contents of this file are subject to the Netscape Public
3* License Version 1.1 (the "License"); you may not use this file
4* except in compliance with the License. You may obtain a copy of
5* the License at http://www.mozilla.org/NPL/
6*
7* Software distributed under the License is distributed on an
8* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed
9* or implied. See the License for the specific language governing
10* rights and limitations under the License.
11*
12* The Original Code is mozilla.org code.
13*
14* The Initial Developer of the Original Code is Netscape
15* Communications Corporation. Portions created by Netscape are
16* Copyright (C) 1998 Netscape Communications Corporation.
17* All Rights Reserved.
18*
19* Contributor(s): pschwartau@netscape.com, crock@veilnetworks.com
20* Date: 2001-07-02
21*
22* SUMMARY: Testing visibility of outer function from inner function.
23*
24*/
25//-------------------------------------------------------------------------------------------------
26var UBound = 0;
27var bug = '(none)';
28var summary = 'Testing visibility of outer function from inner function';
29var cnCousin = 'Fred';
30var cnColor = 'red';
31var cnMake = 'Toyota';
32var status = '';
33var statusitems = [];
34var actual = '';
35var actualvalues = [];
36var expect= '';
37var expectedvalues = [];
38
39
40// TEST 1
41function Outer()
42{
43
44 function inner()
45 {
46 Outer.cousin = cnCousin;
47 return Outer.cousin;
48 }
49
50 status = 'Section 1 of test';
51 actual = inner();
52 expect = cnCousin;
53 addThis();
54}
55
56
57Outer();
58status = 'Section 2 of test';
59actual = Outer.cousin;
60expect = cnCousin;
61addThis();
62
63
64
65// TEST 2
66function Car(make)
67{
68 this.make = make;
69 Car.prototype.paint = paint;
70
71 function paint()
72 {
73 Car.color = cnColor;
74 Car.prototype.color = Car.color;
75 }
76}
77
78
79var myCar = new Car(cnMake);
80status = 'Section 3 of test';
81actual = myCar.make;
82expect = cnMake;
83addThis();
84
85
86myCar.paint();
87status = 'Section 4 of test';
88actual = myCar.color;
89expect = cnColor;
90addThis();
91
92
93
94//--------------------------------------------------
95test();
96//--------------------------------------------------
97
98
99
100function addThis()
101{
102 statusitems[UBound] = status;
103 actualvalues[UBound] = actual;
104 expectedvalues[UBound] = expect;
105 UBound++;
106}
107
108
109function test()
110{
111 enterFunc ('test');
112 printBugNumber (bug);
113 printStatus (summary);
114
115 for (var i=0; i<UBound; i++)
116 {
117 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
118 }
119
120 exitFunc ('test');
121}