michael@0: // vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: michael@0: function w(y) michael@0: { michael@0: var x = 23.5; michael@0: return x & y; michael@0: } michael@0: michael@0: function f(x, y) { michael@0: // Confuse the type analysis to not know the type of x. michael@0: var t = 3.5 + x; michael@0: t + 3.5; michael@0: return x & y; michael@0: } michael@0: michael@0: function g_bool(x, y) { michael@0: var t; michael@0: if (x + 0) michael@0: t = true; michael@0: else michael@0: t = false; michael@0: return t & y; michael@0: michael@0: } michael@0: michael@0: function g_null(x) { michael@0: return null & x; michael@0: } michael@0: michael@0: var obj = { valueOf: function () { return 5; } } michael@0: michael@0: assertEq(w(93), 21); michael@0: assertEq(g_bool(1, 3), 1); michael@0: assertEq(g_bool(0, 3), 0); michael@0: assertEq(g_null(2), 0); michael@0: michael@0: assertEq(f(1, 7), 1); michael@0: assertEq(f(true, 7), 1); michael@0: assertEq(f(false, 7), 0); michael@0: assertEq(f("3", 7), 3); michael@0: assertEq(f(obj, 7), 5); michael@0: assertEq(f(3.5, 7), 3); michael@0: assertEq(f(undefined, 7), 0); michael@0: assertEq(f(null, 7), 0); michael@0: assertEq(f(Math.NaN, 7), 0); michael@0: