| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
var gTestfile = 'regress-137000.js'; |
| 19 |
var UBound = 0; |
| 20 |
var BUGNUMBER = 137000; |
| 21 |
var summary = 'Function param or local var with same name as a function prop'; |
| 22 |
var status = ''; |
| 23 |
var statusitems = []; |
| 24 |
var actual = ''; |
| 25 |
var actualvalues = []; |
| 26 |
var expect= ''; |
| 27 |
var expectedvalues = []; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
function f(x) |
| 35 |
{ |
| 36 |
} |
| 37 |
|
| 38 |
status = inSection(1); |
| 39 |
f.x = 12; |
| 40 |
actual = f.x; |
| 41 |
expect = 12; |
| 42 |
addThis(); |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
function parentObject(p) |
| 54 |
{ |
| 55 |
this.p = 1; |
| 56 |
} |
| 57 |
|
| 58 |
function childObject() |
| 59 |
{ |
| 60 |
parentObject.call(this); |
| 61 |
} |
| 62 |
childObject.prototype = parentObject; |
| 63 |
|
| 64 |
status = inSection(2); |
| 65 |
var objParent = new parentObject(); |
| 66 |
actual = objParent.p; |
| 67 |
expect = 1; |
| 68 |
addThis(); |
| 69 |
|
| 70 |
status = inSection(3); |
| 71 |
var objChild = new childObject(); |
| 72 |
actual = objChild.p; |
| 73 |
expect = 1; |
| 74 |
addThis(); |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
function Base(id) |
| 83 |
{ |
| 84 |
} |
| 85 |
|
| 86 |
function Child(id) |
| 87 |
{ |
| 88 |
this.prop = id; |
| 89 |
} |
| 90 |
Child.prototype=Base; |
| 91 |
|
| 92 |
status = inSection(4); |
| 93 |
var c1 = new Child('child1'); |
| 94 |
actual = c1.prop; |
| 95 |
expect = 'child1'; |
| 96 |
addThis(); |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
function BaseX(id) |
| 104 |
{ |
| 105 |
} |
| 106 |
|
| 107 |
function ChildX(id) |
| 108 |
{ |
| 109 |
this.id = id; |
| 110 |
} |
| 111 |
ChildX.prototype=BaseX; |
| 112 |
|
| 113 |
status = inSection(5); |
| 114 |
c1 = new ChildX('child1'); |
| 115 |
actual = c1.id; |
| 116 |
expect = 'child1'; |
| 117 |
addThis(); |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
function g() |
| 128 |
{ |
| 129 |
var propA = g.propA; |
| 130 |
var propB = g.propC; |
| 131 |
|
| 132 |
this.getVarA = function() {return propA;} |
| 133 |
this.getVarB = function() {return propB;} |
| 134 |
} |
| 135 |
g.propA = 'A'; |
| 136 |
g.propB = 'B'; |
| 137 |
g.propC = 'C'; |
| 138 |
var obj = new g(); |
| 139 |
|
| 140 |
status = inSection(6); |
| 141 |
actual = obj.getVarA(); |
| 142 |
expect = 'A'; |
| 143 |
addThis(); |
| 144 |
|
| 145 |
status = inSection(7); |
| 146 |
actual = obj.getVarB(); |
| 147 |
expect = 'C'; |
| 148 |
addThis(); |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
function setFProperty(val) |
| 162 |
{ |
| 163 |
F.propA = val; |
| 164 |
} |
| 165 |
|
| 166 |
function F() |
| 167 |
{ |
| 168 |
var propA = 'Local variable in F'; |
| 169 |
} |
| 170 |
|
| 171 |
status = inSection(8); |
| 172 |
setFProperty('Hello'); |
| 173 |
actual = F.propA; |
| 174 |
expect = 'Hello'; |
| 175 |
addThis(); |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
test(); |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
function addThis() |
| 187 |
{ |
| 188 |
statusitems[UBound] = status; |
| 189 |
actualvalues[UBound] = actual; |
| 190 |
expectedvalues[UBound] = expect; |
| 191 |
UBound++; |
| 192 |
} |
| 193 |
|
| 194 |
|
| 195 |
function test() |
| 196 |
{ |
| 197 |
enterFunc('test'); |
| 198 |
printBugNumber(BUGNUMBER); |
| 199 |
printStatus(summary); |
| 200 |
|
| 201 |
for (var i=0; i<UBound; i++) |
| 202 |
{ |
| 203 |
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 204 |
} |
| 205 |
|
| 206 |
exitFunc ('test'); |
| 207 |
} |