Author: Carl Friedrich Bolz <[email protected]>
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):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit