From: Stefan Behnel Date: Thu, 11 Feb 2010 21:21:27 +0000 (+0100) Subject: extended test case X-Git-Tag: 0.13.beta0~340^2~23 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ca354aabf9219c5adf888e4c99ef6f5129e515e4;p=cython.git extended test case --- diff --git a/tests/run/carray_slicing.pyx b/tests/run/carray_slicing.pyx index dedaf676..c3b78689 100644 --- a/tests/run/carray_slicing.pyx +++ b/tests/run/carray_slicing.pyx @@ -118,9 +118,9 @@ for i in range(6): @cython.test_assert_path_exists("//ForFromStatNode", "//ForFromStatNode//IndexNode") @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] [1, 2, 3, 4] [4, 5] @@ -133,10 +133,62 @@ def slice_intptr_for_loop_c(): @cython.test_assert_path_exists("//ForFromStatNode", "//ForFromStatNode//IndexNode") @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] """ cdef int i 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 ]