fpizlo@apple.com | 0e6e154 | 2013-03-18 18:09:22 +0000 | [diff] [blame] | 1 | description( |
2 | "Tests that we do ToString conversions correctly when String.prototype.valueOf is initially fine but then gets clobbered." | ||||
3 | ); | ||||
4 | |||||
5 | function foo(a) { | ||||
6 | for (var i = 0; i < 100; ++i) | ||||
7 | a = new String(a); | ||||
8 | return a; | ||||
9 | } | ||||
10 | |||||
11 | var expected = "\"hello\""; | ||||
12 | for (var i = 0; i < 150; ++i) { | ||||
13 | if (i == 100) { | ||||
14 | String.prototype.valueOf = function() { return 42; } | ||||
15 | expected = "\"42\""; | ||||
16 | } | ||||
17 | shouldBe("\"\" + foo(\"hello\")", expected); | ||||
18 | } | ||||
19 |