本文整理汇总了Python中pypy.objspace.std.inttype.wrapint函数的典型用法代码示例。如果您正苦于以下问题:Python wrapint函数的具体用法?Python wrapint怎么用?Python wrapint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wrapint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pow_iin
def test_pow_iin(self):
x = 10
y = 2
f1 = wrapint(self.space, x)
f2 = wrapint(self.space, y)
v = self.space.pow(f1, f2, self.space.w_None)
assert v.intval == x ** y
示例2: test_and
def test_and(self):
x = 12345678
y = 2
f1 = wrapint(self.space, x)
f2 = wrapint(self.space, y)
v = self.space.and_(f1, f2)
assert v.intval == x & y
示例3: test_rshift
def test_rshift(self):
x = 12345678
y = 2
f1 = wrapint(self.space, x)
f2 = wrapint(self.space, y)
v = self.space.rshift(f1, f2)
assert v.intval == x >> y
示例4: test_mul
def test_mul(self):
for x in [0, 1, 100, sys.maxint // 2 - 50, sys.maxint - 1000]:
for y in [0, 1, 100, sys.maxint // 2 - 50, sys.maxint - 1000]:
f1 = wrapint(self.space, x)
f2 = wrapint(self.space, y)
result = self.space.unwrap(self.space.mul(f1, f2))
assert result == x*y and type(result) == type(x*y)
示例5: test_or
def test_or(self):
x = 12345678
y = 2
f1 = wrapint(self.space, x)
f2 = wrapint(self.space, y)
v = self.space.or_(f1, f2)
assert v.intval == x | y
示例6: test_div
def test_div(self):
for i in range(10):
res = i//3
f1 = wrapint(self.space, i)
f2 = wrapint(self.space, 3)
result = self.space.div(f1, f2)
assert result.intval == res
示例7: test_mod
def test_mod(self):
x = 1
y = 2
f1 = wrapint(self.space, x)
f2 = wrapint(self.space, y)
v = self.space.mod(f1, f2)
assert v.intval == x % y
示例8: test_divmod
def test_divmod(self):
x = 1
y = 2
f1 = wrapint(self.space, x)
f2 = wrapint(self.space, y)
ret = self.space.divmod(f1, f2)
v, w = self.space.unwrap(ret)
assert (v, w) == divmod(x, y)
示例9: test_add
def test_add(self):
for x in [1, 100, sys.maxint // 2 - 50,
sys.maxint // 2, sys.maxint - 1000, sys.maxint]:
for y in [1, 100, sys.maxint // 2 - 50,
sys.maxint // 2, sys.maxint - 1000, sys.maxint]:
f1 = wrapint(self.space, x)
f2 = wrapint(self.space, y)
result = self.space.unwrap(self.space.add(f1, f2))
assert result == x+y
示例10: len__RopeIter
def len__RopeIter(space, w_ropeiter):
if w_ropeiter.node is None:
return wrapint(space, 0)
index = w_ropeiter.index
length = w_ropeiter.node.length()
result = length - index
if result < 0:
return wrapint(space, 0)
return wrapint(space, result)
示例11: test_abs
def test_abs(self):
x = 42
f1 = wrapint(self.space, x)
v = self.space.abs(f1)
assert v.intval == abs(x)
x = -42
f1 = wrapint(self.space, x)
v = self.space.abs(f1)
assert v.intval == abs(x)
示例12: test_sub
def test_sub(self):
for x in [1, 100, sys.maxint // 2 - 50,
sys.maxint // 2, sys.maxint - 1000, sys.maxint]:
for y in [1, 100, sys.maxint // 2 - 50,
sys.maxint // 2, sys.maxint - 1000, sys.maxint]:
f1 = wrapint(self.space, x)
f2 = wrapint(self.space, y)
result = self.space.unwrap(self.space.sub(f1, f2))
assert result == x-y and type(result) == type(x-y)
示例13: len__RangeIter
def len__RangeIter(space, w_rangeiter):
if w_rangeiter.w_rangelist is None:
return wrapint(space, 0)
index = w_rangeiter.index
w_length = space.len(w_rangeiter.w_rangelist)
w_len = space.sub(w_length, wrapint(space, index))
if space.is_true(space.lt(w_len, wrapint(space, 0))):
w_len = wrapint(space, 0)
return w_len
示例14: test_pos
def test_pos(self):
x = 42
f1 = wrapint(self.space, x)
v = self.space.pos(f1)
assert v.intval == +x
x = -42
f1 = wrapint(self.space, x)
v = self.space.pos(f1)
assert v.intval == +x
示例15: test_compare
def test_compare(self):
import operator
optab = ['lt', 'le', 'eq', 'ne', 'gt', 'ge']
for x in (-10, -1, 0, 1, 2, 1000, sys.maxint):
for y in (-sys.maxint-1, -11, -9, -2, 0, 1, 3, 1111, sys.maxint):
for op in optab:
wx = wrapint(self.space, x)
wy = wrapint(self.space, y)
res = getattr(operator, op)(x, y)
method = getattr(self.space, op)
myres = method(wx, wy)
assert self.space.unwrap(myres) == res