michael@0: function testBitOrAnyInconvertibleObject() michael@0: { michael@0: var count = 0; michael@0: function toString() { ++count; if (count == 95) return {}; return count; } michael@0: var o = {valueOf: undefined, toString: toString}; michael@0: michael@0: var threw = false; michael@0: try michael@0: { michael@0: for (var i = 0; i < 100; i++) michael@0: var q = 1 | o; michael@0: } michael@0: catch (e) michael@0: { michael@0: threw = true; michael@0: if (i !== 94) michael@0: return "expected i === 94, got " + i; michael@0: if (q !== 95) michael@0: return "expected q === 95, got " + q; michael@0: if (count !== 95) michael@0: return "expected count === 95, got " + count; michael@0: } michael@0: if (!threw) michael@0: return "expected throw with 2 | o"; // hey, a rhyme! michael@0: michael@0: return "pass"; michael@0: } michael@0: assertEq(testBitOrAnyInconvertibleObject(), "pass");