[pypy-commit] cffi cpy-extension: Tests and fix.

arigo noreply at buildbot.pypy.org
Tue Jun 12 17:50:36 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: cpy-extension
Changeset: r296:db9a3e7636ef
Date: 2012-06-12 17:50 +0200
http://bitbucket.org/cffi/cffi/changeset/db9a3e7636ef/

Log:	Tests and fix.

diff --git a/cffi/verifier.py b/cffi/verifier.py
--- a/cffi/verifier.py
+++ b/cffi/verifier.py
@@ -165,7 +165,7 @@
             for i in rng:
                 prnt('  PyObject *arg%d;' % i)
             prnt()
-            prnt('  if (!PyArg_ParseTuple("%s:%s", %s)) {' % (
+            prnt('  if (!PyArg_ParseTuple(args, "%s:%s", %s))' % (
                 'O' * numargs, name, ', '.join(['&arg%d' % i for i in rng])))
             prnt('    return NULL;')
         prnt()
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -66,6 +66,18 @@
     assert lib.foo("A") == "B"
     py.test.raises(TypeError, lib.foo, "bar")
 
+def test_no_argument():
+    ffi = FFI()
+    ffi.cdef("int foo(void);")
+    lib = ffi.verify("int foo() { return 42; }")
+    assert lib.foo() == 42
+
+def test_two_arguments():
+    ffi = FFI()
+    ffi.cdef("int foo(int, int);")
+    lib = ffi.verify("int foo(int a, int b) { return a - b; }")
+    assert lib.foo(40, -2) == 42
+
 
 def test_verify_typedefs():
     py.test.skip("XXX?")


More information about the pypy-commit mailing list