Example #1
0
 def test_bug(self):
     import _cffi_backend
     LONG = _cffi_backend.new_primitive_type('long')
     five = _cffi_backend.cast(LONG, 5)
     raises(TypeError, list, five)
     DOUBLE = _cffi_backend.new_primitive_type('double')
     five_and_a_half = _cffi_backend.cast(DOUBLE, 5.5)
     raises(TypeError, list, five_and_a_half)
Example #2
0
 def test_bug(self):
     import _cffi_backend
     LONG = _cffi_backend.new_primitive_type('long')
     five = _cffi_backend.cast(LONG, 5)
     raises(TypeError, list, five)
     DOUBLE = _cffi_backend.new_primitive_type('double')
     five_and_a_half = _cffi_backend.cast(DOUBLE, 5.5)
     raises(TypeError, list, five_and_a_half)
Example #3
0
 def test_TypeError_if_no_length(self):
     import _cffi_backend
     LONG = _cffi_backend.new_primitive_type('long')
     P_LONG = _cffi_backend.new_pointer_type(LONG)
     LONG_ARRAY = _cffi_backend.new_array_type(P_LONG, 3)
     buf = _cffi_backend.newp(LONG_ARRAY)
     pbuf = _cffi_backend.cast(P_LONG, buf)
     raises(TypeError, "list(pbuf)")
Example #4
0
 def test_TypeError_if_no_length(self):
     import _cffi_backend
     LONG = _cffi_backend.new_primitive_type('long')
     P_LONG = _cffi_backend.new_pointer_type(LONG)
     LONG_ARRAY = _cffi_backend.new_array_type(P_LONG, 3)
     buf = _cffi_backend.newp(LONG_ARRAY)
     pbuf = _cffi_backend.cast(P_LONG, buf)
     raises(TypeError, "list(pbuf)")
Example #5
0
        def main(libm_name):
            try:
                import _cffi_backend
            except ImportError:
                sys.stderr.write('SKIP: cannot import _cffi_backend\n')
                return 0

            libm = _cffi_backend.load_library(libm_name)
            BDouble = _cffi_backend.new_primitive_type("double")
            BInt = _cffi_backend.new_primitive_type("int")
            BPow = _cffi_backend.new_function_type([BDouble, BInt], BDouble)
            ldexp = libm.load_function(BPow, 'ldexp')
            i = 0
            res = 0
            while i < 300:
                tmp = ldexp(1, 3)  # ID: cfficall
                res += tmp
                i += 1
            BLong = _cffi_backend.new_primitive_type("long")
            ldexp_addr = int(_cffi_backend.cast(BLong, ldexp))
            return ldexp_addr, res
Example #6
0
        def main(libm_name):
            try:
                import _cffi_backend
            except ImportError:
                sys.stderr.write('SKIP: cannot import _cffi_backend\n')
                return 0

            libm = _cffi_backend.load_library(libm_name)
            BDouble = _cffi_backend.new_primitive_type("double")
            BInt = _cffi_backend.new_primitive_type("int")
            BPow = _cffi_backend.new_function_type([BDouble, BInt], BDouble)
            ldexp = libm.load_function(BPow, 'ldexp')
            i = 0
            res = 0
            while i < 300:
                tmp = ldexp(1, 3)   # ID: cfficall
                res += tmp
                i += 1
            BLong = _cffi_backend.new_primitive_type("long")
            ldexp_addr = int(_cffi_backend.cast(BLong, ldexp))
            return ldexp_addr, res