Пример #1
0
def test_simple():
    ffi = FFI(backend=FakeBackend())
    ffi.cdef("double sin(double x);")
    m = ffi.load("m")
    func = m.sin    # should be a callable on real backends
    assert func.name == 'sin'
    assert func.BType == '<func (<double>), <double>, False>'
Пример #2
0
def test_simple():
    ffi = FFI(backend=FakeBackend())
    ffi.cdef("double sin(double x);")
    m = ffi.load("m")
    func = m.sin  # should be a callable on real backends
    assert func.name == 'sin'
    assert func.BType == '<func (<double>), <double>, False>'
Пример #3
0
 def test_sin(self):
     ffi = FFI(backend=self.Backend())
     ffi.cdef("""
         double sin(double x);
     """)
     m = ffi.load("m")
     x = m.sin(1.23)
     assert x == math.sin(1.23)
Пример #4
0
 def test_sin(self):
     ffi = FFI(backend=self.Backend())
     ffi.cdef("""
         double sin(double x);
     """)
     m = ffi.load("m")
     x = m.sin(1.23)
     assert x == math.sin(1.23)
Пример #5
0
 def test_getting_errno(self):
     ffi = FFI(backend=self.Backend())
     ffi.cdef("""
         int test_getting_errno(void);
     """)
     ownlib = ffi.load(self.module)
     res = ownlib.test_getting_errno()
     assert res == -1
     assert ffi.C.errno == 123
Пример #6
0
 def test_getting_errno(self):
     ffi = FFI(backend=self.Backend())
     ffi.cdef("""
         int test_getting_errno(void);
     """)
     ownlib = ffi.load(self.module)
     res = ownlib.test_getting_errno()
     assert res == -1
     assert ffi.C.errno == 123
Пример #7
0
 def test_sinf(self):
     ffi = FFI(backend=self.Backend())
     ffi.cdef("""
         float sinf(float x);
     """)
     m = ffi.load("m")
     x = m.sinf(1.23)
     assert type(x) is float
     assert x != math.sin(1.23)    # rounding effects
     assert abs(x - math.sin(1.23)) < 1E-6
Пример #8
0
 def test_sinf(self):
     ffi = FFI(backend=self.Backend())
     ffi.cdef("""
         float sinf(float x);
     """)
     m = ffi.load("m")
     x = m.sinf(1.23)
     assert type(x) is float
     assert x != math.sin(1.23)  # rounding effects
     assert abs(x - math.sin(1.23)) < 1E-6
Пример #9
0
 def test_setting_errno(self):
     if self.Backend is CTypesBackend and '__pypy__' in sys.modules:
         py.test.skip("XXX errno issue with ctypes on pypy?")
     ffi = FFI(backend=self.Backend())
     ffi.cdef("""
         int test_setting_errno(void);
     """)
     ownlib = ffi.load(self.module)
     ffi.C.errno = 42
     res = ownlib.test_setting_errno()
     assert res == 42
     assert ffi.C.errno == 42
Пример #10
0
 def test_setting_errno(self):
     if self.Backend is CTypesBackend and '__pypy__' in sys.modules:
         py.test.skip("XXX errno issue with ctypes on pypy?")
     ffi = FFI(backend=self.Backend())
     ffi.cdef("""
         int test_setting_errno(void);
     """)
     ownlib = ffi.load(self.module)
     ffi.C.errno = 42
     res = ownlib.test_setting_errno()
     assert res == 42
     assert ffi.C.errno == 42