1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
function getval(o) { return obj.val } function f(x, o) { var lhs = -(~x >>> 0) var rhs = getval(o) return (lhs - rhs >> 0) } function getObj(v) { return { val: v } } var obj = getObj(1) assertEq(f(0, obj), 0) assertEq(f(0, obj), 0) obj = getObj('can has bug?') obj = getObj(.5) assertEq(f(0, obj), 1)