| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-252892.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 252892; |
| 9 |
var summary = 'for (var i in o) in heavyweight function f should define i in f\'s activation'; |
| 10 |
var actual = ''; |
| 11 |
var expect = ''; |
| 12 |
|
| 13 |
printBugNumber(BUGNUMBER); |
| 14 |
printStatus (summary); |
| 15 |
|
| 16 |
var status; |
| 17 |
|
| 18 |
var dodis; |
| 19 |
|
| 20 |
function f1(o){for(var x in o)printStatus(o[x]); return x} |
| 21 |
function f2(o){with(this)for(var x in o)printStatus(o[x]); return x} |
| 22 |
function f2novar(o){with(this)for(x in o)printStatus(o[x]); return x} |
| 23 |
function f3(i,o){for(var x=i in o)printStatus(o[x]); return x} |
| 24 |
function f4(i,o){with(this)for(var x=i in o)printStatus(o[x]); return x} |
| 25 |
|
| 26 |
const f1src = |
| 27 |
"function f1(o) {\n" + |
| 28 |
" for (var x in o) {\n" + |
| 29 |
" printStatus(o[x]);\n" + |
| 30 |
" }\n" + |
| 31 |
" return x;\n" + |
| 32 |
"}"; |
| 33 |
|
| 34 |
const f2src = |
| 35 |
"function f2(o) {\n" + |
| 36 |
" with (this) {\n" + |
| 37 |
" for (var x in o) {\n" + |
| 38 |
" printStatus(o[x]);\n" + |
| 39 |
" }\n" + |
| 40 |
" }\n" + |
| 41 |
" return x;\n" + |
| 42 |
"}"; |
| 43 |
|
| 44 |
const f2novarsrc = |
| 45 |
"function f2novar(o) {\n" + |
| 46 |
" with (this) {\n" + |
| 47 |
" for (x in o) {\n" + |
| 48 |
" printStatus(o[x]);\n" + |
| 49 |
" }\n" + |
| 50 |
" }\n" + |
| 51 |
" return x;\n" + |
| 52 |
"}"; |
| 53 |
|
| 54 |
const f3src = |
| 55 |
"function f3(i, o) {\n" + |
| 56 |
" var x = i;\n" + |
| 57 |
" for (x in o) {\n" + |
| 58 |
" printStatus(o[x]);\n" + |
| 59 |
" }\n" + |
| 60 |
" return x;\n" + |
| 61 |
"}"; |
| 62 |
|
| 63 |
const f4src = |
| 64 |
"function f4(i, o) {\n" + |
| 65 |
" with (this) {\n" + |
| 66 |
" var x = i;\n" + |
| 67 |
" for (x in o) {\n" + |
| 68 |
" printStatus(o[x]);\n" + |
| 69 |
" }\n" + |
| 70 |
" }\n" + |
| 71 |
" return x;\n" + |
| 72 |
"}"; |
| 73 |
|
| 74 |
var t=0; |
| 75 |
function assert(c) |
| 76 |
{ |
| 77 |
++t; |
| 78 |
|
| 79 |
status = summary + ' ' + inSection(t); |
| 80 |
expect = true; |
| 81 |
actual = c; |
| 82 |
|
| 83 |
if (!c) |
| 84 |
{ |
| 85 |
printStatus(t + " FAILED!"); |
| 86 |
} |
| 87 |
reportCompare(expect, actual, summary); |
| 88 |
} |
| 89 |
|
| 90 |
if (dodis && this.dis) dis(f1); |
| 91 |
assert(f1 == f1src); |
| 92 |
|
| 93 |
if (dodis && this.dis) dis(f2); |
| 94 |
assert(f2 == f2src); |
| 95 |
|
| 96 |
if (dodis && this.dis) dis(f2novar); |
| 97 |
assert(f2novar == f2novarsrc); |
| 98 |
|
| 99 |
if (dodis && this.dis) dis(f3); |
| 100 |
assert(f3 == f3src); |
| 101 |
|
| 102 |
if (dodis && this.dis) dis(f4); |
| 103 |
assert(f4 == f4src); |
| 104 |
|
| 105 |
assert(f1([]) == undefined); |
| 106 |
|
| 107 |
assert(f1(['first']) == 0); |
| 108 |
|
| 109 |
assert(f2([]) == undefined); |
| 110 |
|
| 111 |
assert(f2(['first']) == 0); |
| 112 |
|
| 113 |
assert(f3(42, []) == 42); |
| 114 |
|
| 115 |
assert(f3(42, ['first']) == 0); |
| 116 |
|
| 117 |
assert(f4(42, []) == 42); |
| 118 |
|
| 119 |
assert(f4(42, ['first']) == 0); |
| 120 |
|
| 121 |
this.x = 41; |
| 122 |
|
| 123 |
assert(f2([]) == undefined); |
| 124 |
|
| 125 |
assert(f2novar([]) == 41); |
| 126 |
|
| 127 |
assert(f2(['first']) == undefined); |
| 128 |
|
| 129 |
assert(f2novar(['first']) == 0); |