Source

cffi / testing / backend_tests.py

Diff from to

testing/backend_tests.py

         t = ffi.typeof("int(*(*)(int))(int)")
         assert repr(t) == self.TypeRepr % "int(*(*)(int))(int)"
 
+    def test_functionptr_voidptr_return(self):
+        ffi = FFI(backend=self.Backend())
+        def cb():
+            return None
+        p = ffi.callback("void*(*)()", cb)
+        res = p()
+        assert res is None
+        int_ptr = ffi.new('int')
+        void_ptr = ffi.cast('void*', int_ptr)
+        def cb():
+            return void_ptr
+        p = ffi.callback("void*(*)()", cb)
+        res = p()
+        assert repr(res) == "<cdata 'void *'>"
+        assert ffi.cast("long", res) != 0
+
     def test_char_cast(self):
         ffi = FFI(backend=self.Backend())
         p = ffi.cast("int", '\x01')