summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2016-08-22 17:40:35 +0200
committerArmin Rigo <arigo@tunes.org>2016-08-22 17:40:35 +0200
commitec18b7f424ff64bb15154bc69c7103b2b36ff072 (patch)
tree38e60aae6447568c0c8b7a0cccdb66fd8c1b2b4f /testing
parent2401c14d0a24079b305cc3ecf36f84a1ea663d7c (diff)
parent4a14e501899044786bbe9c906f8bb3147d529c33 (diff)
downloadcffi-ec18b7f424ff64bb15154bc69c7103b2b36ff072.tar.gz
merge heads
Diffstat (limited to 'testing')
-rw-r--r--testing/cffi1/test_recompiler.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/testing/cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py
index 59e1e3e..248c619 100644
--- a/testing/cffi1/test_recompiler.py
+++ b/testing/cffi1/test_recompiler.py
@@ -1962,3 +1962,21 @@ def test_function_returns_opaque():
ffi, "test_function_returns_opaque", "?")
assert str(e.value) == ("function foo: 'struct a' is used as result type,"
" but is opaque")
+
+def test_function_returns_union():
+ ffi = FFI()
+ ffi.cdef("union u1 { int a, b; }; union u1 f1(int);")
+ lib = verify(ffi, "test_function_returns_union", """
+ union u1 { int a, b; };
+ static union u1 f1(int x) { union u1 u; u.b = x; return u; }
+ """)
+ assert lib.f1(51).a == 51
+
+def test_function_returns_partial_struct():
+ ffi = FFI()
+ ffi.cdef("struct a { int a; ...; }; struct a f1(int);")
+ lib = verify(ffi, "test_function_returns_partial_struct", """
+ struct a { int b, a, c; };
+ static struct a f1(int x) { struct a s = {0}; s.a = x; return s; }
+ """)
+ assert lib.f1(52).a == 52