[pypy-svn] r75508 - in pypy/branch/fast-ctypes/pypy/rlib: . test
getxsick at codespeak.net
getxsick at codespeak.net
Tue Jun 22 19:59:56 CEST 2010
Author: getxsick
Date: Tue Jun 22 19:59:54 2010
New Revision: 75508
Modified:
pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py
pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py
Log:
providing W_LibHandler class broke rlib.rjitffi a bit (and i just noticed it)
so here is a dirty fix for it, also tests updated and new added
Modified: pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py (original)
+++ pypy/branch/fast-ctypes/pypy/rlib/rjitffi.py Tue Jun 22 19:59:54 2010
@@ -28,7 +28,11 @@
self.args_type = args_type
self.res_type = res_type
self.cpu = cpu
- self.lib = lib.handler
+
+ if hasattr(lib, 'handler'):
+ self.lib = lib.handler
+ else:
+ self.lib = lib
if self.res_type == 'int':
self.bres = BoxInt()
Modified: pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py
==============================================================================
--- pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py (original)
+++ pypy/branch/fast-ctypes/pypy/rlib/test/test_rjitffi.py Tue Jun 22 19:59:54 2010
@@ -63,17 +63,17 @@
lib = rjitffi.CDLL(self.lib_name)
func = lib.get('add_integers', ['int', 'int'], 'int')
- assert 3 == func.call(1,2)
+ assert 3 == func.call([1,2])
func = lib.get('add_integers', ['int', 'int'], 'int')
- assert 1 == func.call(-1,2)
+ assert 1 == func.call([-1,2])
func = lib.get('add_integers', ['int', 'int'], 'int')
- assert 0 == func.call(0,0)
+ assert 0 == func.call([0,0])
func = lib.get('max3', ['int', 'int', 'int'], 'int')
- assert 8 == func.call(2, 8, 3)
+ assert 8 == func.call([2, 8, 3])
func = lib.get('add_floats', ['float', 'float'], 'float')
- assert 2.7 == func.call(1.2, 1.5)
+ assert 2.7 == func.call([1.2, 1.5])
def test_get_void(self):
lib = rjitffi.CDLL(self.lib_name)
@@ -82,12 +82,20 @@
assert 1 == func.call()
func = lib.get('return_void', ['int', 'int'], 'void')
- assert func.call(1, 2) is None
+ assert func.call([1, 2]) is None
func = lib.get('return_void', ['int', 'int'])
- assert func.call(1, 2) is None
+ assert func.call([1, 2]) is None
def test_undefined_func(self):
lib = rjitffi.CDLL(self.lib_name)
# xxxfoo888baryyy - not existed function
py.test.raises(ValueError, lib.get, 'xxxfoo888baryyy', [])
py.test.raises(ValueError, lib.get, 'xxxfoo888baryyy', ['int'], 'int')
+
+ def test_unknown_types(self):
+ lib = rjitffi.CDLL(self.lib_name)
+ # xxxfoo888baryyy - not defined types (args_type, res_type etc.)
+ py.test.raises(ValueError, lib.get, 'fvoid', ['xxxfoo888baryyy'])
+ py.test.raises(ValueError, lib.get, 'fvoid', ['int','xxxfoo888baryyy'])
+ py.test.raises(ValueError, lib.get, 'fvoid', ['xxxfoo888baryyy'],'int')
+ py.test.raises(ValueError, lib.get, 'fvoid', [], 'xxxfoo888baryyy')
More information about the Pypy-commit
mailing list