| OLD | NEW |
| (Empty) |
| 1 description( | |
| 2 "Tests that defining a setter on the prototype of an object used for indexed sto
rage works even if it is done after objects with indexed storage are allocated." | |
| 3 ); | |
| 4 | |
| 5 function Cons() { | |
| 6 } | |
| 7 | |
| 8 var ouches = 0; | |
| 9 | |
| 10 function foo(haveABadTime) { | |
| 11 var result = new Cons(); | |
| 12 result.length = 5; | |
| 13 for (var i = 0; i < result.length; ++i) { | |
| 14 if (i == haveABadTime) { | |
| 15 debug("Henceforth I will have a bad time."); | |
| 16 Cons.prototype.__defineSetter__("3", function() { debug("Ouch!"); ou
ches++; }); | |
| 17 } | |
| 18 result[i] = i; | |
| 19 } | |
| 20 return result; | |
| 21 } | |
| 22 | |
| 23 var expected = "\"0,1,2,3,4\""; | |
| 24 | |
| 25 for (var i = 0; i < 1000; ++i) { | |
| 26 var haveABadTime; | |
| 27 if (i == 950) { | |
| 28 haveABadTime = 2; | |
| 29 expected = "\"0,1,2,,4\""; | |
| 30 } else | |
| 31 haveABadTime = -1; | |
| 32 shouldBe("\"" + Array.prototype.join.apply(foo(haveABadTime), [","]) + "\"",
expected); | |
| 33 } | |
| 34 | |
| 35 shouldBe("ouches", "50"); | |
| OLD | NEW |