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/
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is mozilla.org code.
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. All
19 * Contributor(s): georg@bioshop.de, pschwartau@netscape.com
20 * Date: 10 September 2001
22 * SUMMARY: Testing with() statement with nested functions
23 * See http://bugzilla.mozilla.org/show_bug.cgi?id=97921
25 * Brendan: "The bug is peculiar to functions that have formal parameters,
26 * but that are called with fewer actual arguments than the declared number
27 * of formal parameters."
29 //-----------------------------------------------------------------------------
32 var summary = 'Testing with() statement with nested functions';
33 var cnYES = 'Inner value === outer value';
34 var cnNO = "Inner value !== outer value!";
38 var actualvalues = [];
40 var expectedvalues = [];
49 if(useWith) with(1){i;}
52 outerValue = i; // capture value of i in outer function
53 F1 = function() {innerValue = i;}; // capture value of i in inner function
58 status = inSection(1);
60 F(); // call F without supplying the argument
61 actual = innerValue === outerValue;
65 status = inSection(2);
67 F(); // call F without supplying the argument
68 actual = innerValue === outerValue;
76 with (new Object()) {i=100};
79 outerValue = i; // capture value of i in outer function
80 G1 = function() {innerValue = i;}; // capture value of i in inner function
85 status = inSection(3);
86 G(); // call G without supplying the argument
87 actual = innerValue === 101;
91 status = inSection(4);
92 G(); // call G without supplying the argument
93 actual = innerValue === outerValue;
99 //-----------------------------------------------------------------------------
101 //-----------------------------------------------------------------------------
106 statusitems[UBound] = status;
107 actualvalues[UBound] = areTheseEqual(actual);
108 expectedvalues[UBound] = areTheseEqual(expect);
116 printBugNumber (bug);
117 printStatus (summary);
119 for (var i = 0; i < UBound; i++)
121 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
128 function areTheseEqual(yes)
130 return yes? cnYES : cnNO