Commit 0725fdd8 authored by Stefan Behnel's avatar Stefan Behnel

test case for ticket 636

parent d9dcbc32
...@@ -18,6 +18,7 @@ for_from_pyvar_loop_T601 ...@@ -18,6 +18,7 @@ for_from_pyvar_loop_T601
decorators_T593 decorators_T593
temp_sideeffects_T654 temp_sideeffects_T654
class_scope_T671 class_scope_T671
slice2_T636
# CPython regression tests that don't current work: # CPython regression tests that don't current work:
pyregr.test_threadsignals pyregr.test_threadsignals
......
# mode: run
# ticket 636
# tag: slicing, getitem
class Sliceable(object):
"""
>>> sl = Sliceable()
>>> sl[1:2]
(1, 2, None)
>>> py_slice2(sl, 1, 2)
(1, 2, None)
>>> sl[1:None]
(1, None, None)
>>> py_slice2(sl, 1, None)
(1, None, None)
>>> sl[None:2]
(None, 2, None)
>>> py_slice2(sl, None, 2)
(None, 2, None)
>>> sl[None:None]
(None, None, None)
>>> py_slice2(sl, None, None)
(None, None, None)
"""
def __getitem__(self, sl):
return (sl.start, sl.stop, sl.step)
def py_slice2(obj,a,b):
"""
>>> [1,2,3][1:2]
[2]
>>> py_slice2([1,2,3], 1, 2)
[2]
>>> [1,2,3][None:2]
[1, 2]
>>> py_slice2([1,2,3], None, 2)
[1, 2]
>>> [1,2,3][None:None]
[1, 2, 3]
>>> py_slice2([1,2,3], None, None)
[1, 2, 3]
"""
return obj[a:b]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment