| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
var gTestfile = 'regress-97921.js'; |
| 18 |
var UBound = 0; |
| 19 |
var BUGNUMBER = 97921; |
| 20 |
var summary = 'Testing with() statement with nested functions'; |
| 21 |
var cnYES = 'Inner value === outer value'; |
| 22 |
var cnNO = "Inner value !== outer value!"; |
| 23 |
var status = ''; |
| 24 |
var statusitems = []; |
| 25 |
var actual = ''; |
| 26 |
var actualvalues = []; |
| 27 |
var expect= ''; |
| 28 |
var expectedvalues = []; |
| 29 |
var outerValue = ''; |
| 30 |
var innerValue = ''; |
| 31 |
var useWith = ''; |
| 32 |
|
| 33 |
|
| 34 |
function F(i) |
| 35 |
{ |
| 36 |
i = 0; |
| 37 |
if(useWith) with(1){i;} |
| 38 |
i++; |
| 39 |
|
| 40 |
outerValue = i; |
| 41 |
F1 = function() {innerValue = i;}; |
| 42 |
F1(); |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
status = inSection(1); |
| 47 |
useWith=false; |
| 48 |
F(); |
| 49 |
actual = innerValue === outerValue; |
| 50 |
expect = true; |
| 51 |
addThis(); |
| 52 |
|
| 53 |
status = inSection(2); |
| 54 |
useWith=true; |
| 55 |
F(); |
| 56 |
actual = innerValue === outerValue; |
| 57 |
expect = true; |
| 58 |
addThis(); |
| 59 |
|
| 60 |
|
| 61 |
function G(i) |
| 62 |
{ |
| 63 |
i = 0; |
| 64 |
with (new Object()) {i=100}; |
| 65 |
i++; |
| 66 |
|
| 67 |
outerValue = i; |
| 68 |
G1 = function() {innerValue = i;}; |
| 69 |
G1(); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
status = inSection(3); |
| 74 |
G(); |
| 75 |
actual = innerValue === 101; |
| 76 |
expect = true; |
| 77 |
addThis(); |
| 78 |
|
| 79 |
status = inSection(4); |
| 80 |
G(); |
| 81 |
actual = innerValue === outerValue; |
| 82 |
expect = true; |
| 83 |
addThis(); |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
test(); |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
function addThis() |
| 93 |
{ |
| 94 |
statusitems[UBound] = status; |
| 95 |
actualvalues[UBound] = areTheseEqual(actual); |
| 96 |
expectedvalues[UBound] = areTheseEqual(expect); |
| 97 |
UBound++; |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
function test() |
| 102 |
{ |
| 103 |
enterFunc ('test'); |
| 104 |
printBugNumber(BUGNUMBER); |
| 105 |
printStatus (summary); |
| 106 |
|
| 107 |
for (var i = 0; i < UBound; i++) |
| 108 |
{ |
| 109 |
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 110 |
} |
| 111 |
|
| 112 |
exitFunc ('test'); |
| 113 |
} |
| 114 |
|
| 115 |
|
| 116 |
function areTheseEqual(yes) |
| 117 |
{ |
| 118 |
return yes? cnYES : cnNO |
| 119 |
} |