| // This file tests the concatenating of known strings with different objects with overridden valueOf functions. |
| // Note: we intentionally do not test Symbols since they cannot be appended to strings... |
| function catNumber(obj) { |
| return "test" + "things" + obj; |
| number = { valueOf: function() { return 1; } }; |
| return "test" + "things" + obj; |
| bool = { valueOf: function() { return true; } }; |
| function catUndefined(obj) { |
| return "test" + "things" + obj; |
| undef = { valueOf: function() { return undefined; } }; |
| function catRandom(obj) { |
| return "test" + "things" + obj; |
| random = { valueOf: function() { |
| for (i = 0; i < 100000; i++) { |
| if (catNumber(number) !== "testthings1") |
| if (catBool(bool) !== "testthingstrue") |
| if (catUndefined(undef) !== "testthingsundefined") |
| if (catRandom(random) !== "testthings" + random.valueOf()) |
| // Try passing new types to each of the other functions. |
| for (i = 0; i < 100000; i++) { |
| if (catUndefined(number) !== "testthings1") |
| if (catNumber(bool) !== "testthingstrue") |
| if (catBool(undef) !== "testthingsundefined") |