[pypy-commit] pypy ffistruct: more tests for type_converter
antocuni
noreply at buildbot.pypy.org
Fri Nov 11 16:32:43 CET 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: ffistruct
Changeset: r49319:470f4d531072
Date: 2011-11-10 22:37 +0100
http://bitbucket.org/pypy/pypy/changeset/470f4d531072/
Log: more tests for 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
@@ -1,4 +1,6 @@
+import sys
from pypy.conftest import gettestobjspace
+from pypy.rlib.rarithmetic import r_uint
from pypy.module._ffi.interp_ffitype import app_types
from pypy.module._ffi.type_converter import FromAppLevelConverter, ToAppLevelConverter
@@ -40,3 +42,19 @@
def test_int(self):
self.check(app_types.sint, self.space.wrap(42), 42)
+ self.check(app_types.sint, self.space.wrap(sys.maxint+1), -sys.maxint-1)
+ self.check(app_types.sint, self.space.wrap(sys.maxint*2), -2)
+
+ def test_uint(self):
+ self.check(app_types.uint, self.space.wrap(42), r_uint(42))
+ self.check(app_types.uint, self.space.wrap(-1), r_uint(sys.maxint*2 +1))
+ self.check(app_types.uint, self.space.wrap(sys.maxint*3),
+ r_uint(sys.maxint - 2))
+
+ def test_pointer(self):
+ # pointers are "unsigned" at applevel, but signed at interp-level (for
+ # 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)
More information about the pypy-commit
mailing list