| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
var gTestfile = 'regress-224956.js'; |
| 16 |
var UBound = 0; |
| 17 |
var BUGNUMBER = 224956; |
| 18 |
var summary = "|expr()| should cause TypeError if |typeof expr| != 'function'"; |
| 19 |
var TEST_PASSED = 'TypeError'; |
| 20 |
var TEST_FAILED = 'Generated an error, but NOT a TypeError! '; |
| 21 |
var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; |
| 22 |
var CHECK_PASSED = 'Should not generate an error'; |
| 23 |
var CHECK_FAILED = 'Generated an error!'; |
| 24 |
var status = ''; |
| 25 |
var statusitems = []; |
| 26 |
var actual = ''; |
| 27 |
var actualvalues = []; |
| 28 |
var expect= ''; |
| 29 |
var expectedvalues = []; |
| 30 |
var x; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
status = inSection(1); |
| 41 |
x = 'abc'; |
| 42 |
testThis('x()'); |
| 43 |
|
| 44 |
status = inSection(2); |
| 45 |
testThis('"abc"()'); |
| 46 |
|
| 47 |
status = inSection(3); |
| 48 |
x = new Date(); |
| 49 |
testThis('x()'); |
| 50 |
|
| 51 |
status = inSection(4); |
| 52 |
testThis('Date(12345)()'); |
| 53 |
|
| 54 |
status = inSection(5); |
| 55 |
x = Number(1); |
| 56 |
testThis('x()'); |
| 57 |
|
| 58 |
status = inSection(6); |
| 59 |
testThis('1()'); |
| 60 |
|
| 61 |
status = inSection(7); |
| 62 |
x = void(0); |
| 63 |
testThis('x()'); |
| 64 |
|
| 65 |
status = inSection(8); |
| 66 |
testThis('void(0)()'); |
| 67 |
|
| 68 |
status = inSection(9); |
| 69 |
x = Math; |
| 70 |
testThis('x()'); |
| 71 |
|
| 72 |
status = inSection(10); |
| 73 |
testThis('Math()'); |
| 74 |
|
| 75 |
status = inSection(11); |
| 76 |
x = Array(5); |
| 77 |
testThis('x()'); |
| 78 |
|
| 79 |
status = inSection(12); |
| 80 |
testThis('[1,2,3,4,5]()'); |
| 81 |
|
| 82 |
status = inSection(13); |
| 83 |
x = [1,2,3].splice(1,2); |
| 84 |
testThis('x()'); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
status = inSection(14); |
| 91 |
x = 'abc'; |
| 92 |
testThis('x(1)'); |
| 93 |
|
| 94 |
status = inSection(15); |
| 95 |
testThis('"abc"(1)'); |
| 96 |
|
| 97 |
status = inSection(16); |
| 98 |
x = new Date(); |
| 99 |
testThis('x(1)'); |
| 100 |
|
| 101 |
status = inSection(17); |
| 102 |
testThis('Date(12345)(1)'); |
| 103 |
|
| 104 |
status = inSection(18); |
| 105 |
x = Number(1); |
| 106 |
testThis('x(1)'); |
| 107 |
|
| 108 |
status = inSection(19); |
| 109 |
testThis('1(1)'); |
| 110 |
|
| 111 |
status = inSection(20); |
| 112 |
x = void(0); |
| 113 |
testThis('x(1)'); |
| 114 |
|
| 115 |
status = inSection(21); |
| 116 |
testThis('void(0)(1)'); |
| 117 |
|
| 118 |
status = inSection(22); |
| 119 |
x = Math; |
| 120 |
testThis('x(1)'); |
| 121 |
|
| 122 |
status = inSection(23); |
| 123 |
testThis('Math(1)'); |
| 124 |
|
| 125 |
status = inSection(24); |
| 126 |
x = Array(5); |
| 127 |
testThis('x(1)'); |
| 128 |
|
| 129 |
status = inSection(25); |
| 130 |
testThis('[1,2,3,4,5](1)'); |
| 131 |
|
| 132 |
status = inSection(26); |
| 133 |
x = [1,2,3].splice(1,2); |
| 134 |
testThis('x(1)'); |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
status = inSection(27); |
| 141 |
var A = 1, C=2, Y=3, T=4, I=5; |
| 142 |
testThis('(((C/A-0.3)/0.2)+((Y/A-3)/4)+((T/A)/0.05)+((0.095-I/A)/0.4))(100/6)'); |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
status = inSection(28); |
| 155 |
x = function (y) {return y+1;}; |
| 156 |
checkThis('x("abc")'); |
| 157 |
|
| 158 |
status = inSection(29); |
| 159 |
checkThis('(function (y) {return y+1;})("abc")'); |
| 160 |
|
| 161 |
status = inSection(30); |
| 162 |
function f(y) { function g() {return y;}; return g();}; |
| 163 |
checkThis('f("abc")'); |
| 164 |
|
| 165 |
status = inSection(31); |
| 166 |
x = /a()/; |
| 167 |
checkThis('x("abc")'); |
| 168 |
|
| 169 |
status = inSection(32); |
| 170 |
x = /a()/gi; |
| 171 |
checkThis('x("abc")'); |
| 172 |
|
| 173 |
status = inSection(33); |
| 174 |
x = RegExp('a()'); |
| 175 |
checkThis('x("abc")'); |
| 176 |
|
| 177 |
status = inSection(34); |
| 178 |
x = new RegExp('a()', 'gi'); |
| 179 |
checkThis('x("")'); |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
test(); |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
function testThis(sInvalidSyntax) |
| 195 |
{ |
| 196 |
expect = TEST_PASSED; |
| 197 |
actual = TEST_FAILED_BADLY; |
| 198 |
|
| 199 |
try |
| 200 |
{ |
| 201 |
eval(sInvalidSyntax); |
| 202 |
} |
| 203 |
catch(e) |
| 204 |
{ |
| 205 |
if (e instanceof TypeError) |
| 206 |
actual = TEST_PASSED; |
| 207 |
else |
| 208 |
actual = TEST_FAILED + e; |
| 209 |
} |
| 210 |
|
| 211 |
statusitems[UBound] = status; |
| 212 |
expectedvalues[UBound] = expect; |
| 213 |
actualvalues[UBound] = actual; |
| 214 |
UBound++; |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
function checkThis(sValidSyntax) |
| 222 |
{ |
| 223 |
expect = CHECK_PASSED; |
| 224 |
actual = CHECK_PASSED; |
| 225 |
|
| 226 |
try |
| 227 |
{ |
| 228 |
eval(sValidSyntax); |
| 229 |
} |
| 230 |
catch(e) |
| 231 |
{ |
| 232 |
actual = CHECK_FAILED; |
| 233 |
} |
| 234 |
|
| 235 |
statusitems[UBound] = status; |
| 236 |
expectedvalues[UBound] = expect; |
| 237 |
actualvalues[UBound] = actual; |
| 238 |
UBound++; |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
function test() |
| 243 |
{ |
| 244 |
enterFunc('test'); |
| 245 |
printBugNumber(BUGNUMBER); |
| 246 |
printStatus(summary); |
| 247 |
|
| 248 |
for (var i=0; i<UBound; i++) |
| 249 |
{ |
| 250 |
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 251 |
} |
| 252 |
|
| 253 |
exitFunc ('test'); |
| 254 |
} |