[pypy-svn] r64160 - pypy/trunk/pypy/module/_rawffi/test

arigo at codespeak.net arigo at codespeak.net
Thu Apr 16 14:46:44 CEST 2009


Author: arigo
Date: Thu Apr 16 14:46:44 2009
New Revision: 64160

Modified:
   pypy/trunk/pypy/module/_rawffi/test/test__rawffi.py
Log:
This test now passes.


Modified: pypy/trunk/pypy/module/_rawffi/test/test__rawffi.py
==============================================================================
--- pypy/trunk/pypy/module/_rawffi/test/test__rawffi.py	(original)
+++ pypy/trunk/pypy/module/_rawffi/test/test__rawffi.py	Thu Apr 16 14:46:44 2009
@@ -528,6 +528,33 @@
         a1.free()
         del cb
 
+    def test_another_callback_in_stackless(self):
+        try:
+            import _stackless
+        except ImportError:
+            skip("only valid in a stackless pypy-c")
+
+        import _rawffi
+        lib = _rawffi.CDLL(self.lib_name)
+        runcallback = lib.ptr('runcallback', ['P'], 'q')
+        def callback():
+            co = _stackless.coroutine()
+            def f():
+                pass
+            try:
+                co.bind(f)
+                co.switch()
+            except RuntimeError:
+                return 1<<42
+            return -5
+
+        cb = _rawffi.CallbackPtr(callback, [], 'q')
+        a1 = cb.byptr()
+        res = runcallback(a1)
+        assert res[0] == 1<<42
+        a1.free()
+        del cb
+
     def test_raising_callback(self):
         import _rawffi, sys
         import StringIO



More information about the Pypy-commit mailing list