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/. */
7
* Date: 10 September 2001
9
* SUMMARY: Testing with() statement with nested functions
10
* See http://bugzilla.mozilla.org/show_bug.cgi?id=97921
12
* Brendan: "The bug is peculiar to functions that have formal parameters,
13
* but that are called with fewer actual arguments than the declared number
14
* of formal parameters."
16
//-----------------------------------------------------------------------------
18
var BUGNUMBER = 97921;
19
var summary = 'Testing with() statement with nested functions';
20
var cnYES = 'Inner value === outer value';
21
var cnNO = "Inner value !== outer value!";
25
var actualvalues = [];
27
var expectedvalues = [];
36
if(useWith) with(1){i;}
39
outerValue = i; // capture value of i in outer function
40
F1 = function() {innerValue = i;}; // capture value of i in inner function
45
status = inSection(1);
47
F(); // call F without supplying the argument
48
actual = innerValue === outerValue;
52
status = inSection(2);
54
F(); // call F without supplying the argument
55
actual = innerValue === outerValue;
63
with (new Object()) {i=100};
66
outerValue = i; // capture value of i in outer function
67
G1 = function() {innerValue = i;}; // capture value of i in inner function
72
status = inSection(3);
73
G(); // call G without supplying the argument
74
actual = innerValue === 101;
78
status = inSection(4);
79
G(); // call G without supplying the argument
80
actual = innerValue === outerValue;
86
//-----------------------------------------------------------------------------
88
//-----------------------------------------------------------------------------
93
statusitems[UBound] = status;
94
actualvalues[UBound] = areTheseEqual(actual);
95
expectedvalues[UBound] = areTheseEqual(expect);
103
printBugNumber(BUGNUMBER);
104
printStatus (summary);
106
for (var i = 0; i < UBound; i++)
108
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
115
function areTheseEqual(yes)
117
return yes? cnYES : cnNO