| OLD | NEW |
| (Empty) |
| 1 // 15.4 Array Objects | |
| 2 // (c) 2001 Harri Porten <porten@kde.org> | |
| 3 | |
| 4 description( | |
| 5 'This test checks for regression against <a href="https://bugs.webkit.org/show_b
ug.cgi?id=4147">4147: Array.toString() and toLocaleString() improvements from KD
E KJS</a>.' | |
| 6 ); | |
| 7 | |
| 8 // backup | |
| 9 var backupNumberToString = Number.prototype.toString; | |
| 10 var backupNumberToLocaleString = Number.prototype.toLocaleString; | |
| 11 var backupRegExpToString = RegExp.prototype.toString; | |
| 12 var backupRegExpToLocaleString = RegExp.prototype.toLocaleString; | |
| 13 | |
| 14 // change functions | |
| 15 Number.prototype.toString = function() { return "toString"; } | |
| 16 Number.prototype.toLocaleString = function() { return "toLocaleString"; } | |
| 17 RegExp.prototype.toString = function() { return "toString2"; } | |
| 18 RegExp.prototype.toLocaleString = function() { return "toLocaleString2"; } | |
| 19 | |
| 20 // the tests | |
| 21 shouldBe("[1].toString()", "'1'"); | |
| 22 shouldBe("[1].toLocaleString()", "'toLocaleString'"); | |
| 23 Number.prototype.toLocaleString = "invalid"; | |
| 24 shouldBe("[1].toLocaleString()", "'1'"); | |
| 25 shouldBe("[/r/].toString()", "'toString2'"); | |
| 26 shouldBe("[/r/].toLocaleString()", "'toLocaleString2'"); | |
| 27 RegExp.prototype.toLocaleString = "invalid"; | |
| 28 shouldBe("[/r/].toLocaleString()", "'toString2'"); | |
| 29 | |
| 30 var caught = false; | |
| 31 try { | |
| 32 [{ toString : 0 }].toString(); | |
| 33 } catch (e) { | |
| 34 caught = true; | |
| 35 } | |
| 36 shouldBeTrue("caught"); | |
| 37 | |
| 38 // restore | |
| 39 Number.prototype.toString = backupNumberToString; | |
| 40 Number.prototype.toLocaleString = backupNumberToLocaleString; | |
| 41 RegExp.prototype.toString = backupRegExpToString; | |
| 42 RegExp.prototype.toLocaleString = backupRegExpToLocaleString; | |
| OLD | NEW |