本文整理汇总了Python中pypy.objspace.std.listobject.W_ListObject类的典型用法代码示例。如果您正苦于以下问题:Python W_ListObject类的具体用法?Python W_ListObject怎么用?Python W_ListObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了W_ListObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_extend_other_with_empty
def test_extend_other_with_empty(self):
space = self.space
w = space.wrap
l = W_ListObject(space, [w(1), w(2), w(3)])
assert isinstance(l.strategy, IntegerListStrategy)
l.extend(W_ListObject(space, []))
assert isinstance(l.strategy, IntegerListStrategy)
开发者ID:Darriall,项目名称:pypy,代码行数:7,代码来源:test_liststrategies.py
示例2: test_float_to_any
def test_float_to_any(self):
l = W_ListObject(self.space, [self.space.wrap(1.1),self.space.wrap(2.2),self.space.wrap(3.3)])
assert isinstance(l.strategy, FloatListStrategy)
l.append(self.space.wrap(4.4))
assert isinstance(l.strategy, FloatListStrategy)
l.append(self.space.wrap("a"))
assert isinstance(l.strategy, ObjectListStrategy)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:test_liststrategies.py
示例3: 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)
开发者ID:Darriall,项目名称:pypy,代码行数:7,代码来源:test_liststrategies.py
示例4: test_string_to_any
def test_string_to_any(self):
l = W_ListObject(self.space, [self.space.wrap('a'),self.space.wrap('b'),self.space.wrap('c')])
assert isinstance(l.strategy, StringListStrategy)
l.append(self.space.wrap('d'))
assert isinstance(l.strategy, StringListStrategy)
l.append(self.space.wrap(3))
assert isinstance(l.strategy, ObjectListStrategy)
开发者ID:craigkerstiens,项目名称:pypy,代码行数:7,代码来源:test_liststrategies.py
示例5: test_int_to_any
def test_int_to_any(self):
l = W_ListObject(self.space, [self.space.wrap(1),self.space.wrap(2),self.space.wrap(3)])
assert isinstance(l.strategy, IntegerListStrategy)
l.append(self.space.wrap(4))
assert isinstance(l.strategy, IntegerListStrategy)
l.append(self.space.wrap('a'))
assert isinstance(l.strategy, ObjectListStrategy)
开发者ID:craigkerstiens,项目名称:pypy,代码行数:7,代码来源:test_liststrategies.py
示例6: test_create_list_from_set
def test_create_list_from_set(self):
from pypy.objspace.std.setobject import W_SetObject
from pypy.objspace.std.setobject import _initialize_set
space = self.space
w = space.wrap
w_l = W_ListObject(space, [space.wrap(1), space.wrap(2), space.wrap(3)])
w_set = W_SetObject(self.space)
_initialize_set(self.space, w_set, w_l)
w_set.iter = None # make sure fast path is used
w_l2 = W_ListObject(space, [])
space.call_method(w_l2, "__init__", w_set)
w_l2.sort(False)
assert space.eq_w(w_l, w_l2)
w_l = W_ListObject(space, [space.wrap("a"), space.wrap("b"), space.wrap("c")])
_initialize_set(self.space, w_set, w_l)
space.call_method(w_l2, "__init__", w_set)
w_l2.sort(False)
assert space.eq_w(w_l, w_l2)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:26,代码来源:test_liststrategies.py
示例7: test_unicode_to_any
def test_unicode_to_any(self):
space = self.space
l = W_ListObject(space, [space.wrap(u'a'), space.wrap(u'b'), space.wrap(u'c')])
assert isinstance(l.strategy, UnicodeListStrategy)
l.append(space.wrap(u'd'))
assert isinstance(l.strategy, UnicodeListStrategy)
l.append(space.wrap(3))
assert isinstance(l.strategy, ObjectListStrategy)
开发者ID:Darriall,项目名称:pypy,代码行数:8,代码来源:test_liststrategies.py
示例8: test_add_does_not_use_getitems
def test_add_does_not_use_getitems(self):
l1 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
l1.getitems = None
l2 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
l2.getitems = None
l3 = self.space.add(l1, l2)
l4 = 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(l3, l4)
开发者ID:craigkerstiens,项目名称:pypy,代码行数:8,代码来源:test_liststrategies.py
示例9: test_mul_does_not_clone
def test_mul_does_not_clone(self):
# only testing right mul at the moment
w = self.space.wrap
arg = w(2)
w_lis = W_ListObject(self.space, [arg])
w_lis.clone = None
# does not crash
self.space.mul(w_lis, w(5))
开发者ID:charred,项目名称:pypy,代码行数:8,代码来源:test_listobject.py
示例10: test_int_or_float_setslice_mixed_5
def test_int_or_float_setslice_mixed_5(self):
space = self.space
w_l1 = W_ListObject(space, [space.wrap(0), space.wrap(1.2)])
w_l2 = W_ListObject(space, [space.wrap(32), space.wrap(45)])
assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
assert isinstance(w_l2.strategy, IntegerListStrategy)
w_l1.setslice(0, 1, 1, w_l2)
assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
assert space.unwrap(w_l1) == [32, 45, 1.2]
开发者ID:Qointum,项目名称:pypy,代码行数:9,代码来源:test_liststrategies.py
示例11: test_int_or_float_extend_mixed_6
def test_int_or_float_extend_mixed_6(self):
space = self.space
w_l1 = W_ListObject(space, [space.wrap(-2.5)])
w_l2 = W_ListObject(space, [space.wrap(3.4), space.wrap(-2)])
assert isinstance(w_l1.strategy, FloatListStrategy)
assert isinstance(w_l2.strategy, IntOrFloatListStrategy)
w_l1.extend(w_l2)
assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
assert space.unwrap(w_l1) == [-2.5, 3.4, -2]
开发者ID:Qointum,项目名称:pypy,代码行数:9,代码来源:test_liststrategies.py
示例12: test_int_or_float_extend
def test_int_or_float_extend(self):
space = self.space
w_l1 = W_ListObject(space, [space.wrap(0), space.wrap(1.2)])
w_l2 = W_ListObject(space, [space.wrap(3), space.wrap(4.5)])
assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
assert isinstance(w_l2.strategy, IntOrFloatListStrategy)
w_l1.extend(w_l2)
assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
assert space.unwrap(w_l1) == [0, 1.2, 3, 4.5]
开发者ID:Qointum,项目名称:pypy,代码行数:9,代码来源:test_liststrategies.py
示例13: test_int_or_float_sort
def test_int_or_float_sort(self):
space = self.space
w_l = W_ListObject(space, [space.wrap(1.2), space.wrap(1),
space.wrap(1.0), space.wrap(5)])
w_l.sort(False)
assert [(type(x), x) for x in space.unwrap(w_l)] == [
(int, 1), (float, 1.0), (float, 1.2), (int, 5)]
w_l.sort(True)
assert [(type(x), x) for x in space.unwrap(w_l)] == [
(int, 5), (float, 1.2), (int, 1), (float, 1.0)]
开发者ID:Qointum,项目名称:pypy,代码行数:10,代码来源:test_liststrategies.py
示例14: test_int_or_float_extend_mixed_1
def test_int_or_float_extend_mixed_1(self):
space = self.space
w_l1 = W_ListObject(space, [space.wrap(0), space.wrap(1.2)])
w_l2 = W_ListObject(space, [space.wrap(3)])
assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
assert isinstance(w_l2.strategy, IntegerListStrategy)
w_l1.extend(w_l2)
assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
assert [(type(x), x) for x in space.unwrap(w_l1)] == [
(int, 0), (float, 1.2), (int, 3)]
开发者ID:Qointum,项目名称:pypy,代码行数:10,代码来源:test_liststrategies.py
示例15: test_int_or_float_from_float
def test_int_or_float_from_float(self):
space = self.space
w = space.wrap
w_l = W_ListObject(space, [space.wrap(-42.5)])
assert isinstance(w_l.strategy, FloatListStrategy)
w_l.append(w(-15))
assert isinstance(w_l.strategy, IntOrFloatListStrategy)
assert space.float_w(w_l.getitem(0)) == -42.5
assert space.int_w(w_l.getitem(1)) == -15
assert space.len_w(w_l) == 2
开发者ID:Qointum,项目名称:pypy,代码行数:10,代码来源:test_liststrategies.py
示例16: test_int_or_float_from_integer
def test_int_or_float_from_integer(self):
space = self.space
w = space.wrap
w_l = W_ListObject(space, [space.wrap(int(-2**31))])
assert isinstance(w_l.strategy, IntegerListStrategy)
w_l.append(w(-5.1))
assert isinstance(w_l.strategy, IntOrFloatListStrategy)
assert space.int_w(w_l.getitem(0)) == -2**31
assert space.float_w(w_l.getitem(1)) == -5.1
assert space.len_w(w_l) == 2
开发者ID:Qointum,项目名称:pypy,代码行数:10,代码来源:test_liststrategies.py
示例17: descr__new__
def descr__new__(space, w_listtype, __args__):
if space.config.objspace.std.withmultilist:
from pypy.objspace.std.listmultiobject import W_ListMultiObject
w_obj = space.allocate_instance(W_ListMultiObject, w_listtype)
W_ListMultiObject.__init__(w_obj, space)
else:
from pypy.objspace.std.listobject import W_ListObject
w_obj = space.allocate_instance(W_ListObject, w_listtype)
W_ListObject.__init__(w_obj, [])
return w_obj
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:10,代码来源:listtype.py
示例18: 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)
开发者ID:craigkerstiens,项目名称:pypy,代码行数:11,代码来源:test_liststrategies.py
示例19: test_int_or_float_setslice_mixed_5_overflow
def test_int_or_float_setslice_mixed_5_overflow(self):
if sys.maxint == 2147483647:
py.test.skip("only on 64-bit")
space = self.space
ovf1 = 2 ** 35
w_l1 = W_ListObject(space, [space.wrap(0), space.wrap(1.2)])
w_l2 = W_ListObject(space, [space.wrap(32), space.wrap(ovf1)])
assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
assert isinstance(w_l2.strategy, IntegerListStrategy)
w_l1.setslice(0, 1, 1, w_l2)
assert isinstance(w_l1.strategy, ObjectListStrategy)
assert space.unwrap(w_l1) == [32, ovf1, 1.2]
开发者ID:Qointum,项目名称:pypy,代码行数:12,代码来源:test_liststrategies.py
示例20: test_int_or_float_extend_mixed_5_overflow
def test_int_or_float_extend_mixed_5_overflow(self):
if sys.maxint == 2147483647:
py.test.skip("only on 64-bit")
space = self.space
ovf1 = 2 ** 35
w_l1 = W_ListObject(space, [space.wrap(-2.5)])
w_l2 = W_ListObject(space, [space.wrap(ovf1)])
assert isinstance(w_l1.strategy, FloatListStrategy)
assert isinstance(w_l2.strategy, IntegerListStrategy)
w_l1.extend(w_l2)
assert isinstance(w_l1.strategy, ObjectListStrategy)
assert space.unwrap(w_l1) == [-2.5, ovf1]
开发者ID:Qointum,项目名称:pypy,代码行数:12,代码来源:test_liststrategies.py
注:本文中的pypy.objspace.std.listobject.W_ListObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论