test that inferring the function pointer type for a C function is enabled in safe...
authorStefan Behnel <scoder@users.berlios.de>
Thu, 13 Jan 2011 16:23:15 +0000 (17:23 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 13 Jan 2011 16:23:15 +0000 (17:23 +0100)
tests/run/type_inference.pyx

index a056fe34284784f58cef48a29ecddc174175aa10..2c5f1809621ee03cb16de1f74dd7893bcef70703 100644 (file)
@@ -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):
     """