def test_math_sin_type():
ffi = FFI()
ffi.cdef("double sin(double);")
lib = verify(ffi, 'test_math_sin_type', '#include <math.h>')
# 'lib.sin' is typed as a <built-in method> object on lib
assert ffi.typeof(lib.sin).cname == "double(*)(double)"
# 'x' is another <built-in method> object on lib, made very indirectly
x = type(lib).__dir__.__get__(lib)
py.test.raises(TypeError, ffi.typeof, x)
#
# present on built-in functions on CPython; must be emulated on PyPy:
assert lib.sin.__name__ == 'sin'
assert lib.sin.__module__ == '_CFFI_test_math_sin_type'
assert lib.sin.__doc__ == 'direct call to the C function of the same name'
评论列表
文章目录