def test_direct(): space = gettestobjspace(**{"objspace.std.withsmalllong": True}) w5 = space.wrap(r_longlong(5)) assert isinstance(w5, W_SmallLongObject) wlarge = space.wrap(r_longlong(0x123456789ABCDEFL)) # assert space.int_w(w5) == 5 if sys.maxint < 0x123456789ABCDEFL: py.test.raises(OperationError, space.int_w, wlarge) else: assert space.int_w(wlarge) == 0x123456789ABCDEF # assert space.pos(w5) is w5 assert space.abs(w5) is w5 wm5 = space.wrap(r_longlong(-5)) assert space.int_w(space.abs(wm5)) == 5 assert space.int_w(space.neg(w5)) == -5 assert space.is_true(w5) is True assert space.is_true(wm5) is True w0 = space.wrap(r_longlong(0)) assert space.is_true(w0) is False # w14000000000000 = space.wrap(r_longlong(0x14000000000000L)) assert space.is_true(space.eq( space.lshift(w5, space.wrap(49)), w14000000000000)) is False assert space.is_true(space.eq( space.lshift(w5, space.wrap(50)), w14000000000000)) is True # w_huge = space.sub(space.lshift(w5, space.wrap(150)), space.wrap(1)) wx = space.and_(w14000000000000, w_huge) assert space.is_true(space.eq(wx, w14000000000000)) w_obj = W_SmallLongObject.fromint(42) assert space.unwrap(w_obj) == 42
def test_direct(space): w5 = space.wrap(r_longlong(5)) assert isinstance(w5, W_SmallLongObject) wlarge = space.wrap(r_longlong(0x123456789ABCDEFL)) # assert space.int_w(w5) == 5 if sys.maxint < 0x123456789ABCDEFL: with pytest.raises(OperationError): space.int_w(wlarge) else: assert space.int_w(wlarge) == 0x123456789ABCDEF # assert space.pos(w5) is w5 assert space.abs(w5) is w5 wm5 = space.wrap(r_longlong(-5)) assert space.int_w(space.abs(wm5)) == 5 assert space.int_w(space.neg(w5)) == -5 assert space.is_true(w5) is True assert space.is_true(wm5) is True w0 = space.wrap(r_longlong(0)) assert space.is_true(w0) is False # w14000000000000 = space.wrap(r_longlong(0x14000000000000L)) assert space.is_true(space.eq( space.lshift(w5, space.wrap(49)), w14000000000000)) is False assert space.is_true(space.eq( space.lshift(w5, space.wrap(50)), w14000000000000)) is True # w_huge = space.sub(space.lshift(w5, space.wrap(150)), space.wrap(1)) wx = space.and_(w14000000000000, w_huge) assert space.is_true(space.eq(wx, w14000000000000)) w_obj = W_SmallLongObject.fromint(42) assert space.unwrap(w_obj) == 42
def newlong(self, val): # val is an int if self.config.objspace.std.withsmalllong: from pypy.objspace.std.smalllongobject import W_SmallLongObject return W_SmallLongObject.fromint(val) return W_LongObject.fromint(self, val)
def newlong(self, val): # val is an int if self.config.objspace.std.withsmalllong: from pypy.objspace.std.smalllongobject import W_SmallLongObject return W_SmallLongObject.fromint(val) return W_LongObject.fromint(self, val)
def _lshift_ovf2small(space, a, b): from pypy.objspace.std.smalllongobject import W_SmallLongObject w_a = W_SmallLongObject.fromint(a) w_b = W_SmallLongObject.fromint(b) return w_a.descr_lshift(space, w_b)
def _lshift_ovf2small(space, a, b): from pypy.objspace.std.smalllongobject import W_SmallLongObject w_a = W_SmallLongObject.fromint(a) w_b = W_SmallLongObject.fromint(b) return w_a.descr_lshift(space, w_b)