Author: Armin Rigo <[email protected]>
Branch:
Changeset: r1033:b8f90396c06f
Date: 2012-11-09 17:12 +0100
http://bitbucket.org/cffi/cffi/changeset/b8f90396c06f/
Log: Add a passing test which is reported to fail on PyPy.
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -4489,6 +4489,14 @@
(inlined.j << 9));
}
+struct _testfunc22_s { int a[10]; };
+static struct _testfunc22_s _testfunc22(int n)
+{
+ struct _testfunc22_s result;
+ result.a[5] = n;
+ return result;
+}
+
static PyObject *b__testfunc(PyObject *self, PyObject *args)
{
/* for testing only */
@@ -4519,6 +4527,7 @@
case 19: f = &_testfunc19; break;
case 20: f = &_testfunc20; break;
case 21: f = &_testfunc21; break;
+ case 22: f = &_testfunc22; break;
default:
PyErr_SetNone(PyExc_ValueError);
return NULL;
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -927,6 +927,16 @@
lst = [(n << i) for (i, n) in enumerate(range(13, 3, -1))]
assert res == sum(lst)
+def test_call_function_22():
+ BInt = new_primitive_type("int")
+ BArray10 = new_array_type(new_pointer_type(BInt), 10)
+ BStruct = new_struct_type("foo")
+ complete_struct_or_union(BStruct, [('a', BArray10, -1)])
+ BFunc22 = new_function_type((BInt,), BStruct, False)
+ f = cast(BFunc22, _testfunc(22))
+ res = f(5432)
+ assert res.a[5] == 5432
+
def test_call_function_9():
BInt = new_primitive_type("int")
BFunc9 = new_function_type((BInt,), BInt, True) # vararg
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit