[pypy-svn] pypy reflex-support: added test for builtin type conversions
wlav
commits-noreply at bitbucket.org
Wed Feb 2 00:51:39 CET 2011
Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r41532:99ad86908454
Date: 2011-02-01 15:50 -0800
http://bitbucket.org/pypy/pypy/changeset/99ad86908454/
Log: added test for builtin type conversions
diff --git a/pypy/module/cppyy/test/test_datatypes.py b/pypy/module/cppyy/test/test_datatypes.py
--- a/pypy/module/cppyy/test/test_datatypes.py
+++ b/pypy/module/cppyy/test/test_datatypes.py
@@ -105,6 +105,7 @@
for i in range(self.N):
assert eval('c.m_%s_array[i]' % names[j]) == b[i]
+# TODO: be able to dissect array.array for its pointers
# exec 'c.m_%s_array2 = b' % names[j] # pointer copies
# b[i] = 28
# for i in range(self.N):
@@ -125,3 +126,20 @@
raises(ValueError, setattr, c, 'm_ulong', -1)
c.destruct()
+
+ def test4TypeConversions(self):
+ """Test conversions between builtin types"""
+
+ import cppyy, sys
+ cppyy_test_data = cppyy.gbl.cppyy_test_data
+
+ c = cppyy_test_data()
+ assert isinstance(c, cppyy_test_data)
+
+
+ c.m_double = -1
+ assert round(c.m_double + 1.0, 8) == 0
+
+ raises(TypeError, c.m_double, 'c')
+ raises(TypeError, c.m_int, -1.)
+ raises(TypeError, c.m_int, 1.)
More information about the Pypy-commit
mailing list