| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-351503-02.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 351503; |
| 9 |
var summary = 'decompilation of TypeError messages'; |
| 10 |
var actual = ''; |
| 11 |
var expect = ''; |
| 12 |
|
| 13 |
test(); |
| 14 |
|
| 15 |
function test() |
| 16 |
{ |
| 17 |
printBugNumber(BUGNUMBER); |
| 18 |
printStatus (summary); |
| 19 |
|
| 20 |
expect = 'TypeError: can\'t convert Object to string'; |
| 21 |
try |
| 22 |
{ |
| 23 |
function p() { return { toString: null } } "fafa".replace(/a/g, p); |
| 24 |
actual = 'No Error'; |
| 25 |
} |
| 26 |
catch(ex) |
| 27 |
{ |
| 28 |
actual = ex + ''; |
| 29 |
} |
| 30 |
reportCompare(expect, actual, summary + ': 1'); |
| 31 |
|
| 32 |
expect = 'TypeError: can\'t convert Object to string'; |
| 33 |
try |
| 34 |
{ |
| 35 |
a=1; b=2; c={toString: null}; "hahbhc".replace(/[abc]/g, eval); |
| 36 |
actual = 'No Error'; |
| 37 |
} |
| 38 |
catch(ex) |
| 39 |
{ |
| 40 |
actual = ex + ''; |
| 41 |
} |
| 42 |
reportCompare(expect, actual, summary + ': 2'); |
| 43 |
|
| 44 |
expect = 'TypeError: can\'t convert ({toString:(function () {yield 4;})}) to primitive type'; |
| 45 |
try |
| 46 |
{ |
| 47 |
3 + ({toString:function(){yield 4} }); |
| 48 |
actual = 'No Error'; |
| 49 |
} |
| 50 |
catch(ex) |
| 51 |
{ |
| 52 |
actual = ex + ''; |
| 53 |
} |
| 54 |
reportCompare(expect, actual, summary + ': 3'); |
| 55 |
|
| 56 |
expect = 'TypeError: ({}) is not a function'; |
| 57 |
try |
| 58 |
{ |
| 59 |
3 + ({toString:({}) }) ; |
| 60 |
actual = 'No Error'; |
| 61 |
} |
| 62 |
catch(ex) |
| 63 |
{ |
| 64 |
actual = ex + ''; |
| 65 |
} |
| 66 |
reportCompare(expect, actual, summary + ': 4'); |
| 67 |
|
| 68 |
expect = 'TypeError: 3 is not a function'; |
| 69 |
try |
| 70 |
{ |
| 71 |
([5].map)(3); |
| 72 |
actual = 'No Error'; |
| 73 |
} |
| 74 |
catch(ex) |
| 75 |
{ |
| 76 |
actual = ex + ''; |
| 77 |
} |
| 78 |
reportCompare(expect, actual, summary + ': 5'); |
| 79 |
|
| 80 |
expect = 'TypeError: 5 is not a function'; |
| 81 |
try |
| 82 |
{ |
| 83 |
(1 + (4))(); |
| 84 |
actual = 'No Error'; |
| 85 |
} |
| 86 |
catch(ex) |
| 87 |
{ |
| 88 |
actual = ex + ''; |
| 89 |
} |
| 90 |
reportCompare(expect, actual, summary + ': 6'); |
| 91 |
} |