[pypy-commit] pypy list-strategies: added more tests for so far uncovered code in listobject.setslice

l.diekmann noreply at buildbot.pypy.org
Wed Nov 23 15:20:12 CET 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: list-strategies
Changeset: r49688:47318b7c592d
Date: 2011-11-23 15:19 +0100
http://bitbucket.org/pypy/pypy/changeset/47318b7c592d/

Log:	added more tests for so far uncovered code in listobject.setslice

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
@@ -774,7 +774,6 @@
             # self.unerase is valid for both of them
             other_items = self.unerase(w_other.lstorage)
         if other_items is items:
-            XXX # untested paths
             if step > 0:
                 # Always copy starting from the right to avoid
                 # having to make a shallow copy in the case where
diff --git a/pypy/objspace/std/test/test_listobject.py b/pypy/objspace/std/test/test_listobject.py
--- a/pypy/objspace/std/test/test_listobject.py
+++ b/pypy/objspace/std/test/test_listobject.py
@@ -779,6 +779,32 @@
         l[::3] = ('a', 'b')
         assert l == ['a', 1, 2, 'b', 4, 5]
 
+    def test_setslice_with_self(self):
+        l = [1,2,3,4]
+        l[:] = l
+        assert l == [1,2,3,4]
+
+        l = [1,2,3,4]
+        l[0:2] = l
+        assert l == [1,2,3,4,3,4]
+
+        l = [1,2,3,4]
+        l[0:2] = l
+        assert l == [1,2,3,4,3,4]
+
+        l = [1,2,3,4,5,6,7,8,9,10]
+        raises(ValueError, "l[5::-1] = l")
+
+        l = [1,2,3,4,5,6,7,8,9,10]
+        raises(ValueError, "l[::2] = l")
+
+        l = [1,2,3,4,5,6,7,8,9,10]
+        l[5:] = l
+        assert l == [1,2,3,4,5,1,2,3,4,5,6,7,8,9,10]
+
+        l = [1,2,3,4,5,6]
+        l[::-1] = l
+        assert l == [6,5,4,3,2,1]
 
     def test_recursive_repr(self):
         l = []


More information about the pypy-commit mailing list