Author: Antonio Cuni <[email protected]>
Branch: ffistruct
Changeset: r49590:77f79b80d773
Date: 2011-11-12 17:30 +0100
http://bitbucket.org/pypy/pypy/changeset/77f79b80d773/
Log: test _as_ffi_pointer_ in type_converter
diff --git a/pypy/module/_ffi/test/test_type_converter.py
b/pypy/module/_ffi/test/test_type_converter.py
--- a/pypy/module/_ffi/test/test_type_converter.py
+++ b/pypy/module/_ffi/test/test_type_converter.py
@@ -56,5 +56,21 @@
# no good reason, at interp-level Signed or Unsigned makes no
# difference for passing bits around)
self.check(app_types.void_p, self.space.wrap(42), 42)
- self.check(
- app_types.void_p, self.space.wrap(sys.maxint+1), -sys.maxint-1)
+ self.check(app_types.void_p, self.space.wrap(sys.maxint+1),
+ -sys.maxint-1)
+
+ def test__as_ffi_pointer_(self):
+ space = self.space
+ w_MyPointerWrapper = space.appexec([], """():
+ import _ffi
+ class MyPointerWrapper(object):
+ def __init__(self, value):
+ self.value = value
+ def _as_ffi_pointer_(self, ffitype):
+ assert ffitype is _ffi.types.void_p
+ return self.value
+
+ return MyPointerWrapper
+ """)
+ w_obj = space.call_function(w_MyPointerWrapper, space.wrap(42))
+ self.check(app_types.void_p, w_obj, 42)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit