From: Stefan Behnel Date: Thu, 13 Jan 2011 16:23:15 +0000 (+0100) Subject: test that inferring the function pointer type for a C function is enabled in safe... X-Git-Tag: 0.14.1rc0~8^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1197cfa7b73aeab9f372dd3115adf6107b776c4d;p=cython.git test that inferring the function pointer type for a C function is enabled in safe type inference mode --- diff --git a/tests/run/type_inference.pyx b/tests/run/type_inference.pyx index a056fe34..2c5f1809 100644 --- a/tests/run/type_inference.pyx +++ b/tests/run/type_inference.pyx @@ -210,14 +210,14 @@ def builtin_type_methods(): append(1) assert l == [1], str(l) -cdef int func(int x): +cdef int cfunc(int x): return x+1 def c_functions(): """ >>> c_functions() """ - f = func + f = cfunc assert typeof(f) == 'int (*)(int)', typeof(f) assert 2 == f(1) @@ -424,6 +424,15 @@ def safe_only(): res = -j assert typeof(j) == "Python object", typeof(j) +@infer_types(None) +def safe_c_functions(): + """ + >>> safe_c_functions() + """ + f = cfunc + assert typeof(f) == 'int (*)(int)', typeof(f) + assert 2 == f(1) + @infer_types(None) def args_tuple_keywords(*args, **kwargs): """