[pypy-commit] pypy default: also add a test for indices4

cfbolz noreply at buildbot.pypy.org
Fri Nov 4 15:28:23 CET 2011


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: 
Changeset: r48753:20285b132dca
Date: 2011-11-04 15:28 +0100
http://bitbucket.org/pypy/pypy/changeset/20285b132dca/

Log:	also add a test for indices4

diff --git a/pypy/objspace/std/test/test_sliceobject.py b/pypy/objspace/std/test/test_sliceobject.py
--- a/pypy/objspace/std/test/test_sliceobject.py
+++ b/pypy/objspace/std/test/test_sliceobject.py
@@ -42,6 +42,23 @@
                             getslice(length, mystart, mystop))
 
 
+    def test_indexes4(self):
+        space = self.space
+        w = space.wrap
+
+        def getslice(length, start, stop, step):
+            return [i for i in range(0, length, step) if start <= i < stop]
+
+        for step in [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, None]:
+            for length in range(5):
+                for start in range(-2*length-2, 2*length+3) + [None]:
+                    for stop in range(-2*length-2, 2*length+3) + [None]:
+                        sl = space.newslice(w(start), w(stop), w(step))
+                        mystart, mystop, mystep, slicelength = sl.indices4(space, length)
+                        assert len(range(length)[start:stop:step]) == slicelength
+                        assert slice(start, stop, step).indices(length) == (
+                                mystart, mystop, mystep)
+
 class AppTest_SliceObject:
     def test_new(self):
         def cmp_slice(sl1, sl2):


More information about the pypy-commit mailing list