[pypy-commit] cffi default: Add a passing test.

arigo noreply at buildbot.pypy.org
Sun Jun 17 10:17:32 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r393:e63d2411b1ab
Date: 2012-06-16 17:25 +0200
http://bitbucket.org/cffi/cffi/changeset/e63d2411b1ab/

Log:	Add a passing test.

diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -379,6 +379,18 @@
     assert lib.foo() == -42
     assert lib.somenumber == -6
 
+def test_access_address_of_variable():
+    # access the address of 'somenumber': need a trick
+    ffi = FFI()
+    ffi.cdef("int somenumber; static int *const somenumberptr;")
+    lib = ffi.verify("""
+        static int somenumber = 2;
+        #define somenumberptr (&somenumber)
+    """)
+    assert lib.somenumber == 2
+    lib.somenumberptr[0] = 42
+    assert lib.somenumber == 42
+
 def test_access_array_variable():
     ffi = FFI()
     ffi.cdef("int foo(int);\n"


More information about the pypy-commit mailing list