[pypy-svn] r50243 - pypy/dist/pypy/rpython/lltypesystem/test
fijal at codespeak.net
fijal at codespeak.net
Tue Jan 1 19:05:11 CET 2008
Author: fijal
Date: Tue Jan 1 19:05:10 2008
New Revision: 50243
Modified:
pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py
Log:
The test that passes, but it shouldn't. It seems that there are two different
wrappers for eating_callback.
Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py Tue Jan 1 19:05:10 2008
@@ -320,7 +320,7 @@
gn = self.compile(g, [])
assert gn() == "c"
- def test_c_callback(self):
+ def eating_callback(self):
h_source = py.code.Source("""
int eating_callback(int arg, int(*call)(int))
{
@@ -338,30 +338,38 @@
eating_callback = llexternal('eating_callback', args, INT,
compilation_info=eci)
+ return eating_callback
+
+ def test_c_callback(self):
+ eating_callback = self.eating_callback()
def g(i):
return i + 3
- def z(i):
- if i:
- raise ValueError()
- else:
- return 0
-
def f():
return eating_callback(3, g)
fn = self.compile(f, [])
assert fn() == 6
- def z2():
- return eating_callback(3, z)
+ def test_double_callback(self):
+ eating_callback = self.eating_callback()
+
+ def one(i):
+ return i
+
+ def two(i):
+ return i + 2
+
+ def f(i):
+ if i > 3:
+ return eating_callback(i, one)
+ else:
+ return eating_callback(i, two)
+
+ fn = self.compile(f, [int])
+ assert fn(4) == 4
+ assert fn(1) == 3
- # this should complain if there are unhandled exceptions inside
- # callbacks, or complain if really raising exception
- #fn = self.compile(z2, [])
- #fn()
- #raises(UnhandledRPythonException, "self.compile(z2, [])")
-
class TestRffiInternals:
def test_struct_create(self):
X = CStruct('xx', ('one', INT))
More information about the pypy-svn
mailing list