msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 1 | function foo(o) { |
| 2 | return String(o); |
| 3 | } |
| 4 | |
| 5 | noInline(foo); |
| 6 | |
| 7 | for (var i = 0; i < 100000; ++i) { |
| 8 | var result = foo(new String("hello")); |
| 9 | if (typeof result != "string") { |
| 10 | describe(result); |
| 11 | throw "Error: result isn't a string"; |
| 12 | } |
| 13 | if (result != "hello") |
| 14 | throw "Error: bad result: " + result; |
| 15 | |
| 16 | result = foo("world"); |
| 17 | if (typeof result != "string") { |
| 18 | describe(result); |
| 19 | throw "Error: result isn't a string"; |
| 20 | } |
| 21 | if (result != "world") |
| 22 | throw "Error: bad result: " + result; |
| 23 | } |
| 24 | |
| 25 | function Foo() { } |
| 26 | |
| 27 | Foo.prototype.toString = function() { return "hello" }; |
| 28 | |
| 29 | var result = foo(new Foo()); |
| 30 | if (typeof result != "string") { |
| 31 | describe(result); |
| 32 | throw "Error: result isn't a string"; |
| 33 | } |
| 34 | if (result != "hello") |
| 35 | throw "Error: bad result: " + result; |