Author: Armin Rigo <ar...@tunes.org> Branch: int-float-list-strategy Changeset: r78391:4cfaef813f82 Date: 2015-07-01 23:26 +0200 http://bitbucket.org/pypy/pypy/changeset/4cfaef813f82/
Log: Some skipped tests (for later maybe) diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py --- a/pypy/objspace/std/listobject.py +++ b/pypy/objspace/std/listobject.py @@ -1448,7 +1448,7 @@ except IndexError: raise else: - w_list.switch_to_object_strategy() + self.switch_to_next_strategy(w_list, w_item) w_list.setitem(index, w_item) def setslice(self, w_list, start, step, slicelength, w_other): @@ -1741,8 +1741,8 @@ def switch_to_next_strategy(self, w_list, w_sample_item): if type(w_sample_item) is W_IntObject: - intval = self.space.int_w(w_sample_item) - if longlong2float.can_encode_int32(intval): + sample_intval = self.space.int_w(w_sample_item) + if longlong2float.can_encode_int32(sample_intval): # xxx we should be able to use the same lstorage, but # there is a typing issue (float vs longlong)... l = self.unerase(w_list.lstorage) @@ -1797,6 +1797,9 @@ else: return False + def list_is_correct_type(self, w_list): + return w_list.strategy is self.space.fromcache(IntOrFloatListStrategy) + class BytesListStrategy(ListStrategy): import_from_mixin(AbstractUnwrappedStrategy) diff --git a/pypy/objspace/std/test/test_liststrategies.py b/pypy/objspace/std/test/test_liststrategies.py --- a/pypy/objspace/std/test/test_liststrategies.py +++ b/pypy/objspace/std/test/test_liststrategies.py @@ -856,6 +856,44 @@ assert space.int_w(w_l.getitem(1)) == 42 assert space.len_w(w_l) == 2 + 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] + + def test_int_or_float_extend_mixed(self): + py.test.skip("XXX not implemented") + # lst = [0]; lst += [1.2] + # lst = [0]; lst += [1.2, 3] + # lst = [1.2]; lst += [0] + # lst = [1.2]; lst += [0, 3.4] + # lst = [0, 1.2]; lst += [3] + # lst = [0, 1.2]; lst += [3.4] + + def test_int_or_float_setslice(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.setslice(0, 1, 1, w_l2) + assert isinstance(w_l1.strategy, IntOrFloatListStrategy) + assert space.unwrap(w_l1) == [3, 4.5, 1.2] + + def test_int_or_float_setslice_mixed(self): + py.test.skip("XXX not implemented") + # lst = [0]; lst[:] = [1.2] + # lst = [0]; lst[:] = [1.2, 3] + # lst = [1.2]; lst[:] = [0] + # lst = [1.2]; lst[:] = [0, 3.4] + # lst = [0, 1.2]; lst[:] = [3] + # lst = [0, 1.2]; lst[:] = [3.4] + class TestW_ListStrategiesDisabled: spaceconfig = {"objspace.std.withliststrategies": False} _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit