本文整理汇总了Python中pypy.objspace.std.listobject.make_range_list函数的典型用法代码示例。如果您正苦于以下问题:Python make_range_list函数的具体用法?Python make_range_list怎么用?Python make_range_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make_range_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rangelist
def test_rangelist(self):
l = make_range_list(self.space, 1,3,7)
assert isinstance(l.strategy, RangeListStrategy)
v = l.pop(5)
assert self.space.eq_w(v, self.space.wrap(16))
assert isinstance(l.strategy, IntegerListStrategy)
l = make_range_list(self.space, 1,3,7)
assert isinstance(l.strategy, RangeListStrategy)
v = l.pop(0)
assert self.space.eq_w(v, self.space.wrap(1))
assert isinstance(l.strategy, RangeListStrategy)
v = l.pop(l.length() - 1)
assert self.space.eq_w(v, self.space.wrap(19))
assert isinstance(l.strategy, RangeListStrategy)
v = l.pop_end()
assert self.space.eq_w(v, self.space.wrap(16))
assert isinstance(l.strategy, RangeListStrategy)
l = make_range_list(self.space, 1,3,7)
assert isinstance(l.strategy, RangeListStrategy)
l.append(self.space.wrap("string"))
assert isinstance(l.strategy, ObjectListStrategy)
l = make_range_list(self.space, 1,1,5)
assert isinstance(l.strategy, RangeListStrategy)
l.append(self.space.wrap(19))
assert isinstance(l.strategy, IntegerListStrategy)
示例2: test_range_reverse_ovf
def test_range_reverse_ovf(self):
l = make_range_list(self.space, 0, -sys.maxint - 1, 1)
assert isinstance(l.strategy, RangeListStrategy)
l.reverse()
assert isinstance(l.strategy, IntegerListStrategy)
l = make_range_list(self.space, 0, -sys.maxint - 1, 1)
l.sort(False)
assert isinstance(l.strategy, IntegerListStrategy)
示例3: test_empty_range
def test_empty_range(self):
l = make_range_list(self.space, 0, 0, 0)
assert isinstance(l.strategy, EmptyListStrategy)
l = make_range_list(self.space, 1, 1, 10)
for i in l.getitems():
assert isinstance(l.strategy, RangeListStrategy)
l.pop(l.length()-1)
assert isinstance(l.strategy, RangeListStrategy)
示例4: test_empty_extend_with_any
def test_empty_extend_with_any(self):
space = self.space
w = space.wrap
wb = space.wrapbytes
empty = W_ListObject(space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
empty.extend(W_ListObject(space, [w(1), w(2), w(3)]))
assert isinstance(empty.strategy, IntegerListStrategy)
empty = W_ListObject(space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
empty.extend(W_ListObject(space, [wb("a"), wb("b"), wb("c")]))
assert isinstance(empty.strategy, BytesListStrategy)
empty = W_ListObject(space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
empty.extend(W_ListObject(space, [w(u"a"), w(u"b"), w(u"c")]))
assert isinstance(empty.strategy, UnicodeListStrategy)
empty = W_ListObject(space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
r = make_range_list(space, 1,3,7)
empty.extend(r)
assert isinstance(empty.strategy, RangeListStrategy)
print empty.getitem(6)
assert space.is_true(space.eq(empty.getitem(1), w(4)))
empty = W_ListObject(space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
r = make_range_list(space, 0, 1, 10)
empty.extend(r)
assert isinstance(empty.strategy, SimpleRangeListStrategy)
assert space.is_true(space.eq(empty.getitem(1), w(1)))
empty = W_ListObject(space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
empty.extend(W_ListObject(space, [w(1), w(2), w(3)]))
assert isinstance(empty.strategy, IntegerListStrategy)
empty = W_ListObject(space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
empty.extend(W_ListObject(space, [w(1.1), w(2.2), w(3.3)]))
assert isinstance(empty.strategy, FloatListStrategy)
empty = W_ListObject(space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
empty.extend(W_ListObject(space, []))
assert isinstance(empty.strategy, EmptyListStrategy)
示例5: test_empty_extend_with_any
def test_empty_extend_with_any(self):
empty = W_ListObject(self.space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
empty.extend(W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)]))
assert isinstance(empty.strategy, IntegerListStrategy)
empty = W_ListObject(self.space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
empty.extend(W_ListObject(self.space, [self.space.wrap("a"), self.space.wrap("b"), self.space.wrap("c")]))
assert isinstance(empty.strategy, StringListStrategy)
empty = W_ListObject(self.space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
r = make_range_list(self.space, 1,3,7)
empty.extend(r)
assert isinstance(empty.strategy, RangeListStrategy)
print empty.getitem(6)
assert self.space.is_true(self.space.eq(empty.getitem(1), self.space.wrap(4)))
empty = W_ListObject(self.space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
empty.extend(W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)]))
assert isinstance(empty.strategy, IntegerListStrategy)
empty = W_ListObject(self.space, [])
assert isinstance(empty.strategy, EmptyListStrategy)
empty.extend(W_ListObject(self.space, []))
assert isinstance(empty.strategy, EmptyListStrategy)
示例6: test_setslice_int_range
def test_setslice_int_range(self):
space = self.space
w = space.wrap
l = W_ListObject(space, [w(1), w(2), w(3)])
assert isinstance(l.strategy, IntegerListStrategy)
l.setslice(0, 1, 2, make_range_list(space, 5, 1, 4))
assert isinstance(l.strategy, IntegerListStrategy)
示例7: test_getitems
def test_getitems(self):
w = self.space.wrap
from pypy.objspace.std.listobject import make_range_list
r = make_range_list(self.space, 1,1,7)
l = [w(1),w(2),w(3),w(4),w(5),w(6),w(7)]
l2 = r.getitems()
for i in range(7):
assert self.space.eq_w(l[i], l2[i])
示例8: test_keep_range
def test_keep_range(self):
# simple list
l = make_range_list(self.space, 1,1,5)
assert isinstance(l.strategy, RangeListStrategy)
x = l.pop(0)
assert self.space.eq_w(x, self.space.wrap(1))
assert isinstance(l.strategy, RangeListStrategy)
l.pop(l.length()-1)
assert isinstance(l.strategy, RangeListStrategy)
l.append(self.space.wrap(5))
assert isinstance(l.strategy, RangeListStrategy)
# complex list
l = make_range_list(self.space, 1,3,5)
assert isinstance(l.strategy, RangeListStrategy)
l.append(self.space.wrap(16))
assert isinstance(l.strategy, RangeListStrategy)
示例9: test_mul
def test_mul(self):
l1 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
l2 = l1.mul(2)
l3 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3), self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
assert self.space.eq_w(l2, l3)
l4 = make_range_list(self.space, 1, 1, 3)
assert self.space.eq_w(l4, l1)
l5 = l4.mul(2)
assert self.space.eq_w(l5, l3)
示例10: test_add_to_rangelist
def test_add_to_rangelist(self):
l1 = make_range_list(self.space, 1, 1, 3)
l2 = W_ListObject(self.space, [self.space.wrap(4), self.space.wrap(5)])
l3 = l1.descr_add(self.space, l2)
assert self.space.eq_w(l3, W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3), self.space.wrap(4), self.space.wrap(5)]))
示例11: test_weird_rangelist_bug
def test_weird_rangelist_bug(self):
space = self.space
l = make_range_list(space, 1, 1, 3)
# should not raise
w_slice = space.newslice(space.wrap(15), space.wrap(2222), space.wrap(1))
assert l.descr_getitem(space, w_slice).strategy == space.fromcache(EmptyListStrategy)
示例12: test_range_setslice
def test_range_setslice(self):
l = make_range_list(self.space, 1, 3, 5)
assert isinstance(l.strategy, RangeListStrategy)
l.setslice(0, 1, 3, W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)]))
assert isinstance(l.strategy, IntegerListStrategy)
示例13: test_simplerangelist
def test_simplerangelist(self):
l = make_range_list(self.space, 0, 1, 10)
assert isinstance(l.strategy, SimpleRangeListStrategy)
v = l.pop(5)
assert self.space.eq_w(v, self.space.wrap(5))
assert isinstance(l.strategy, IntegerListStrategy)
l = make_range_list(self.space, 0, 1, 10)
assert isinstance(l.strategy, SimpleRangeListStrategy)
v = l.pop(0)
assert self.space.eq_w(v, self.space.wrap(0))
assert isinstance(l.strategy, IntegerListStrategy)
l = make_range_list(self.space, 0, 1, 10)
assert isinstance(l.strategy, SimpleRangeListStrategy)
v = l.pop_end()
assert self.space.eq_w(v, self.space.wrap(9))
assert isinstance(l.strategy, SimpleRangeListStrategy)
v = l.pop_end()
assert self.space.eq_w(v, self.space.wrap(8))
assert isinstance(l.strategy, SimpleRangeListStrategy)
l = make_range_list(self.space, 0, 1, 5)
assert isinstance(l.strategy, SimpleRangeListStrategy)
l.append(self.space.wrap("string"))
assert isinstance(l.strategy, ObjectListStrategy)
l = make_range_list(self.space, 0,1,5)
assert isinstance(l.strategy, SimpleRangeListStrategy)
l.append(self.space.wrap(19))
assert isinstance(l.strategy, IntegerListStrategy)
l = make_range_list(self.space, 0,1,5)
assert isinstance(l.strategy, SimpleRangeListStrategy)
assert l.find(self.space.wrap(0)) == 0
assert l.find(self.space.wrap(4)) == 4
try:
l.find(self.space.wrap(5))
except ValueError:
pass
else:
assert False, "Did not raise ValueError"
try:
l.find(self.space.wrap(0), 5, 6)
except ValueError:
pass
else:
assert False, "Did not raise ValueError"
assert l.length() == 5
l = make_range_list(self.space, 0, 1, 1)
assert self.space.eq_w(l.pop(0), self.space.wrap(0))
l = make_range_list(self.space, 0, 1, 10)
l.sort(False)
assert isinstance(l.strategy, SimpleRangeListStrategy)
assert self.space.eq_w(l.getitem(5), self.space.wrap(5))
l = make_range_list(self.space, 0, 1, 1)
assert self.space.eq_w(l.pop_end(), self.space.wrap(0))
assert isinstance(l.strategy, EmptyListStrategy)
示例14: test_range_getslice_ovf
def test_range_getslice_ovf(self):
l = make_range_list(self.space, -sys.maxint, sys.maxint // 10, 21)
assert isinstance(l.strategy, RangeListStrategy)
l2 = l.getslice(0, 21, 11, 2)
assert isinstance(l2.strategy, IntegerListStrategy)
示例15: test_add_of_range_and_int
def test_add_of_range_and_int(self):
l1 = make_range_list(self.space, 0, 1, 100)
l2 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
l3 = self.space.add(l2, l1)
assert l3.strategy is l2.strategy