Commit ca354aab authored by Stefan Behnel's avatar Stefan Behnel

extended test case

parent 881a4c61
...@@ -118,9 +118,9 @@ for i in range(6): ...@@ -118,9 +118,9 @@ for i in range(6):
@cython.test_assert_path_exists("//ForFromStatNode", @cython.test_assert_path_exists("//ForFromStatNode",
"//ForFromStatNode//IndexNode") "//ForFromStatNode//IndexNode")
@cython.test_fail_if_path_exists("//ForInStatNode") @cython.test_fail_if_path_exists("//ForInStatNode")
def slice_intptr_for_loop_c(): def slice_intarray_for_loop_c():
""" """
>>> slice_intptr_for_loop_c() >>> slice_intarray_for_loop_c()
[0, 1, 2] [0, 1, 2]
[1, 2, 3, 4] [1, 2, 3, 4]
[4, 5] [4, 5]
...@@ -133,10 +133,62 @@ def slice_intptr_for_loop_c(): ...@@ -133,10 +133,62 @@ def slice_intptr_for_loop_c():
@cython.test_assert_path_exists("//ForFromStatNode", @cython.test_assert_path_exists("//ForFromStatNode",
"//ForFromStatNode//IndexNode") "//ForFromStatNode//IndexNode")
@cython.test_fail_if_path_exists("//ForInStatNode") @cython.test_fail_if_path_exists("//ForInStatNode")
def iter_intptr_for_loop_c(): def iter_intarray_for_loop_c():
""" """
>>> iter_intptr_for_loop_c() >>> iter_intarray_for_loop_c()
[0, 1, 2, 3, 4, 5] [0, 1, 2, 3, 4, 5]
""" """
cdef int i cdef int i
print [ i for i in cints ] print [ i for i in cints ]
@cython.test_assert_path_exists("//ForFromStatNode",
"//ForFromStatNode//IndexNode")
@cython.test_fail_if_path_exists("//ForInStatNode")
def slice_intptr_for_loop_c():
"""
>>> slice_intptr_for_loop_c()
[0, 1, 2]
[1, 2, 3, 4]
[4, 5]
"""
cdef int* nums = cints
cdef int i
print [ i for i in nums[:3] ]
print [ i for i in nums[1:5] ]
print [ i for i in nums[4:6] ]
############################################################
# tests for slicing other arrays
cdef double cdoubles[6]
for i in range(6):
cdoubles[i] = i + 0.1
cdef double* cdoubles_ptr = cdoubles
@cython.test_assert_path_exists("//ForFromStatNode",
"//ForFromStatNode//IndexNode")
@cython.test_fail_if_path_exists("//ForInStatNode")
def slice_doublptr_for_loop_c():
"""
>>> slice_doublptr_for_loop_c()
[0.1, 1.1, 2.1]
[1.1, 2.1, 3.1, 4.1]
[4.1, 5.1]
"""
cdef double d
print [ d for d in cdoubles_ptr[:3] ]
print [ d for d in cdoubles_ptr[1:5] ]
print [ d for d in cdoubles_ptr[4:6] ]
@cython.test_assert_path_exists("//ForFromStatNode",
"//ForFromStatNode//IndexNode")
@cython.test_fail_if_path_exists("//ForInStatNode")
def iter_doublearray_for_loop_c():
"""
>>> iter_doublearray_for_loop_c()
[0.1, 1.1, 2.1, 3.1, 4.1, 5.1]
"""
cdef double d
print [ d for d in cdoubles ]
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