From: Stefan Behnel Date: Thu, 7 Feb 2013 22:52:52 +0000 (+0100) Subject: add test for keyword arguments passed into cdef functions with optional arguments... X-Git-Tag: 0.19b1~217 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=edfb4a444b771ba536f701189f38a906b9c8f9c5;p=platform%2Fupstream%2Fpython-cython.git add test for keyword arguments passed into cdef functions with optional arguments, fix parameter names in test --- diff --git a/tests/run/cdef_function_kwargs.pyx b/tests/run/cdef_function_kwargs.pyx index f110135..c9c0449 100644 --- a/tests/run/cdef_function_kwargs.pyx +++ b/tests/run/cdef_function_kwargs.pyx @@ -8,6 +8,9 @@ cdef cfunc(a,b,c,d): cpdef cpfunc(a,b,c,d): return (a,b,c,d) +cdef optargs(a, b=2, c=3): + return (a,b,c) + sideeffect = [] cdef side_effect(x): @@ -111,7 +114,45 @@ def libc_strstr(): return ( strstr("xabcy", "abc") is not NULL, strstr("abc", "xabcy") is NULL, - strstr(NEEDLE="abc", HAYSTACK="xabcz") is not NULL, - strstr(NEEDLE="xabcz", HAYSTACK="abc") is NULL, - strstr(HAYSTACK="abc", NEEDLE="xabcz") is NULL, + strstr(needle="abc", haystack="xabcz") is not NULL, + strstr(needle="xabcz", haystack="abc") is NULL, + strstr(haystack="abc", needle="xabcz") is NULL, ) + + +@cython.test_fail_if_path_exists('//GeneralCallNode') +@cython.test_assert_path_exists('//SimpleCallNode') +def cdef_optargs(): + """ + >>> cdef_optargs() + (11, 2, 3) + (11, 2, 3) + (11, 12, 3) + (11, 12, 3) + (11, 12, 3) + (11, 12, 3) + (11, 12, 3) + (11, 12, 13) + (11, 12, 13) + (11, 12, 13) + (11, 12, 13) + (11, 12, 13) + (11, 12, 13) + (11, 12, 13) + """ + print(optargs(11)) + print(optargs(a=11)) + + print(optargs(11, 12)) + print(optargs(11, b=12)) + print(optargs(a=11, b=12)) + print(optargs(b=12, a=11)) + print(optargs(a=11, b=12)) + + print(optargs(11, 12, 13)) + print(optargs(11, 12, c=13)) + print(optargs(11, c=13, b=12)) + print(optargs(a=11, b=12, c=13)) + print(optargs(b=12, a=11, c=13)) + print(optargs(b=12, c=13, a=11)) + print(optargs(c=13, a=11, b=12))