Commit 86828d2f authored by Armin Rigo's avatar Armin Rigo
Browse files

Add a passing test

parent e6af39664545
......@@ -838,6 +838,22 @@ def test_address_of_function():
assert isinstance(addr, ffi.CData)
assert ffi.typeof(addr) == ffi.typeof("long(*)(long)")
def test_address_of_function_with_struct():
ffi = FFI()
ffi.cdef("struct foo_s { int x; }; long myfunc(struct foo_s);")
lib = verify(ffi, "test_addressof_function_with_struct", """
struct foo_s { int x; };
char myfunc(struct foo_s input) { return (char)(input.x + 42); }
""")
s = ffi.new("struct foo_s *", [5])[0]
assert lib.myfunc(s) == 47
assert not isinstance(lib.myfunc, ffi.CData)
assert ffi.typeof(lib.myfunc) == ffi.typeof("long(*)(struct foo_s)")
addr = ffi.addressof(lib, 'myfunc')
assert addr(s) == 47
assert isinstance(addr, ffi.CData)
assert ffi.typeof(addr) == ffi.typeof("long(*)(struct foo_s)")
def test_issue198():
ffi = FFI()
ffi.cdef("""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment