[pypy-svn] r51375 - in pypy/dist/pypy/objspace/std: . test
fijal at codespeak.net
fijal at codespeak.net
Sun Feb 10 18:51:22 CET 2008
Author: fijal
Date: Sun Feb 10 18:51:21 2008
New Revision: 51375
Modified:
pypy/dist/pypy/objspace/std/objspace.py
pypy/dist/pypy/objspace/std/test/test_stdobjspace.py
Log:
space.sliceindices (needs more testing, coming in a moment)
Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py (original)
+++ pypy/dist/pypy/objspace/std/objspace.py Sun Feb 10 18:51:21 2008
@@ -598,6 +598,13 @@
len(t), expected_length)
return t
+ def sliceindices(self, w_slice, w_length):
+ if isinstance(w_slice, W_SliceObject):
+ a, b, c = w_slice.indices3(self, self.int_w(w_length))
+ return self.newtuple([a, b, c])
+ w_indices = self.getattr(w_slice, self.wrap('indices'))
+ return self.call_function(w_indices, w_length)
+
def is_(self, w_one, w_two):
# XXX a bit of hacking to gain more speed
if w_one is w_two:
Modified: pypy/dist/pypy/objspace/std/test/test_stdobjspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_stdobjspace.py (original)
+++ pypy/dist/pypy/objspace/std/test/test_stdobjspace.py Sun Feb 10 18:51:21 2008
@@ -1,7 +1,5 @@
from pypy.interpreter.error import OperationError
-
-
class TestW_StdObjSpace:
def test_wrap_wrap(self):
@@ -33,3 +31,11 @@
assert ('pop', True) in res
assert ('reverse', True) in res
assert ('popitem', True) not in res
+
+ def test_sliceindices(self):
+ space = self.space
+ w = space.wrap
+ w_slice = space.newslice(w(1), w(2), w(1))
+ assert space.unpacktuple(space.sliceindices(w_slice, w(3))) == [1,2,1]
+
+
More information about the Pypy-commit
mailing list