summaryrefslogtreecommitdiff
path: root/testing/test_verify.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2012-06-15 19:47:39 +0200
committerArmin Rigo <arigo@tunes.org>2012-06-15 19:47:39 +0200
commit3f1480be3531d040092733e0bd58e477fd9be124 (patch)
tree268e858d05c38840fb52892ff09e1b4c70bb1487 /testing/test_verify.py
parent69a400f6ceed5929da584c7a30adca849104b041 (diff)
downloadcffi-3f1480be3531d040092733e0bd58e477fd9be124.tar.gz
Global variables. Needed a bit of refactoring: we cannot return
directly the extension module any more, because we need to have the global variable as a property.
Diffstat (limited to 'testing/test_verify.py')
-rw-r--r--testing/test_verify.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/testing/test_verify.py b/testing/test_verify.py
index e614b47..9ccc6f9 100644
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -332,7 +332,8 @@ def test_full_enum():
"enum ee { EE1, EE3, EE2 };")
assert str(e.value) == 'in enum ee: EE2 has the real value 2, not 1'
# extra items cannot be seen and have no bad consequence anyway
- ffi.verify("enum ee { EE1, EE2, EE3, EE4 };")
+ lib = ffi.verify("enum ee { EE1, EE2, EE3, EE4 };")
+ assert lib.EE3 == 2
def test_get_set_errno():
ffi = FFI()
@@ -356,3 +357,19 @@ def test_define_int():
"#define BAR (-44)\n")
assert lib.FOO == 42
assert lib.BAR == -44
+
+def test_access_variable():
+ ffi = FFI()
+ ffi.cdef("int foo(void);\n"
+ "int somenumber;")
+ lib = ffi.verify("""
+ static int somenumber = 2;
+ static int foo(void) {
+ return somenumber * 7;
+ }
+ """)
+ assert lib.somenumber == 2
+ assert lib.foo() == 14
+ lib.somenumber = -6
+ assert lib.foo() == -42
+ assert lib.somenumber == -6