[pypy-svn] r76048 - pypy/branch/reflex-support/pypy/module/cppyy/test

wlav at codespeak.net wlav at codespeak.net
Thu Jul 8 20:04:22 CEST 2010


Author: wlav
Date: Thu Jul  8 20:04:20 2010
New Revision: 76048

Modified:
   pypy/branch/reflex-support/pypy/module/cppyy/test/test_cppyy.py
   pypy/branch/reflex-support/pypy/module/cppyy/test/test_pythonify.py
Log:
Some more tests.


Modified: pypy/branch/reflex-support/pypy/module/cppyy/test/test_cppyy.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/test/test_cppyy.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/test/test_cppyy.py	Thu Jul  8 20:04:20 2010
@@ -31,10 +31,10 @@
     def setup_class(cls):
         cls.space = space
         env = os.environ
-        cls.w_example01 = cls.space.appexec([], """():
+        cls.w_example01, cls.w_payload = cls.space.unpackiterable(cls.space.appexec([], """():
             import cppyy
             cppyy.load_lib(%r)
-            return cppyy._type_byname('example01')""" % (shared_lib, ))
+            return cppyy._type_byname('example01'), cppyy._type_byname('payload')""" % (shared_lib, )))
 
     def test_example01static_int(self):
         """Test passing of an int, returning of an int, and overloading on a
@@ -133,3 +133,16 @@
         instance.destruct()
         assert t.invoke("getCount") == 0
 
+    def testPassingOfAnObjectByPointer(self):
+        """Test passing of an instance as an argument."""
+
+        t = self.example01
+
+        pl = self.payload.construct(3.14)
+        assert round(pl.invoke("getData")-3.14, 8) == 0
+        
+        t.invoke("setPayload", pl, 41.)    # now pl is a CPPInstance
+        assert pl.invoke("getData") == 41.
+        
+        pl.destruct() 
+        assert t.invoke("getCount") == 0

Modified: pypy/branch/reflex-support/pypy/module/cppyy/test/test_pythonify.py
==============================================================================
--- pypy/branch/reflex-support/pypy/module/cppyy/test/test_pythonify.py	(original)
+++ pypy/branch/reflex-support/pypy/module/cppyy/test/test_pythonify.py	Thu Jul  8 20:04:20 2010
@@ -134,6 +134,8 @@
         assert pl.getData() == 41.
         example01_class.setPayload(pl, 43.)
         assert pl.getData() == 43.
+        e.setPayload(pl, 45.)
+        assert pl.getData() == 45.
 
         pl.destruct()
         e.destruct()



More information about the Pypy-commit mailing list