[pypy-commit] cffi cffi-1.0: Add the extra tests from test_ffi_backend.py
arigo
noreply at buildbot.pypy.org
Sun Apr 26 10:59:41 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1834:40b66d3965df
Date: 2015-04-26 10:51 +0200
http://bitbucket.org/cffi/cffi/changeset/40b66d3965df/
Log: Add the extra tests from test_ffi_backend.py
diff --git a/_cffi1/test_new_ffi_1.py b/_cffi1/test_new_ffi_1.py
--- a/_cffi1/test_new_ffi_1.py
+++ b/_cffi1/test_new_ffi_1.py
@@ -64,6 +64,7 @@
union { int c, d; };
};
struct abc50 { int a, b; int c[50]; };
+ struct ints_and_bitfield { int a,b,c,d,e; int x:1; };
"""
DEFS_PACKED = """
struct is_packed { char a; int b; } /*here*/;
@@ -1581,3 +1582,24 @@
assert s[0].a == b'X'
assert s[1].b == -4892220
assert s[1].a == b'Y'
+
+ def test_not_supported_bitfield_in_result(self):
+ # struct ints_and_bitfield { int a,b,c,d,e; int x:1; };
+ e = py.test.raises(NotImplementedError, ffi.callback,
+ "struct ints_and_bitfield foo(void)", lambda: 42)
+ assert str(e.value) == ("struct ints_and_bitfield(*)(): "
+ "callback with unsupported argument or return type or with '...'")
+
+ def test_inspecttype(self):
+ assert ffi.typeof("long").kind == "primitive"
+ assert ffi.typeof("long(*)(long, long**, ...)").cname == (
+ "long(*)(long, long * *, ...)")
+ assert ffi.typeof("long(*)(long, long**, ...)").ellipsis is True
+
+ def test_new_handle(self):
+ o = [2, 3, 4]
+ p = ffi.new_handle(o)
+ assert ffi.typeof(p) == ffi.typeof("void *")
+ assert ffi.from_handle(p) is o
+ assert ffi.from_handle(ffi.cast("char *", p)) is o
+ py.test.raises(RuntimeError, ffi.from_handle, ffi.NULL)
More information about the pypy-commit
mailing list