예제 #1
0
 def test_extension_object_extra_sources(self):
     ffi = FFI()
     ffi.cdef("double test1eoes(double x);")
     extra_source = str(udir.join('extension_extra_sources.c'))
     with open(extra_source, 'w') as f:
         f.write('double test1eoes(double x) { return x * 6.0; }\n')
     csrc = '/*9%s*/' % self + '''
     double test1eoes(double x);   /* or #include "extra_sources.h" */
     '''
     lib = ffi.verify(csrc, sources=[extra_source],
                      force_generic_engine=self.generic)
     assert lib.test1eoes(7.0) == 42.0
     v = ffi.verifier
     ext = v.get_extension()
     assert 'distutils.extension.Extension' in str(ext.__class__)
     assert ext.sources == [maybe_relative_path(v.sourcefilename),
                            extra_source]
     assert ext.name == v.get_module_name()
 def test_extension_object(self):
     ffi = FFI()
     ffi.cdef("double sin(double x);")
     csrc = '/*7%s*/' % self + '''
 #include <math.h>
 #ifndef TEST_EXTENSION_OBJECT
 # error "define_macros missing"
 #endif
 '''
     lib = ffi.verify(csrc, define_macros=[('TEST_EXTENSION_OBJECT', '1')],
                      force_generic_engine=self.generic)
     assert lib.sin(12.3) == math.sin(12.3)
     v = ffi.verifier
     ext = v.get_extension()
     assert 'distutils.extension.Extension' in str(ext.__class__)
     assert ext.sources == [maybe_relative_path(v.sourcefilename)]
     assert ext.name == v.get_module_name()
     assert ext.define_macros == [('TEST_EXTENSION_OBJECT', '1')]
예제 #3
0
 def test_extension_object_extra_sources(self):
     ffi = FFI()
     ffi.cdef("double test1eoes(double x);")
     extra_source = str(udir.join('extension_extra_sources.c'))
     with open(extra_source, 'w') as f:
         f.write('double test1eoes(double x) { return x * 6.0; }\n')
     csrc = '/*9%s*/' % self + '''
     double test1eoes(double x);   /* or #include "extra_sources.h" */
     '''
     lib = ffi.verify(csrc, sources=[extra_source],
                      force_generic_engine=self.generic)
     assert lib.test1eoes(7.0) == 42.0
     v = ffi.verifier
     ext = v.get_extension()
     assert 'distutils.extension.Extension' in str(ext.__class__)
     assert ext.sources == [maybe_relative_path(v.sourcefilename),
                            extra_source]
     assert ext.name == v.get_module_name()
예제 #4
0
 def test_extension_object(self):
     ffi = FFI()
     ffi.cdef("double sin(double x);")
     csrc = '/*7%s*/' % self + '''
 #include <math.h>
 #ifndef TEST_EXTENSION_OBJECT
 # error "define_macros missing"
 #endif
 '''
     lib = ffi.verify(csrc, define_macros=[('TEST_EXTENSION_OBJECT', '1')],
                      force_generic_engine=self.generic,
                      libraries=[self.lib_m])
     assert lib.sin(12.3) == math.sin(12.3)
     v = ffi.verifier
     ext = v.get_extension()
     assert 'distutils.extension.Extension' in str(ext.__class__)
     assert ext.sources == [maybe_relative_path(v.sourcefilename)]
     assert ext.name == v.get_module_name()
     assert ext.define_macros == [('TEST_EXTENSION_OBJECT', '1')]
예제 #5
0
def test_different_absolute():
    p = os.path.join('..', 'baz.py')
    assert maybe_relative_path(p) == p
예제 #6
0
def test_not_absolute():
    assert maybe_relative_path('foo/bar') == 'foo/bar'
    assert maybe_relative_path('test_platform.py') == 'test_platform.py'
예제 #7
0
def test_absolute_mapping():
    p = os.path.abspath('baz.py')
    assert maybe_relative_path(p) == 'baz.py'
    foobaz = os.path.join('foo', 'baz.py')
    assert maybe_relative_path(os.path.abspath(foobaz)) == foobaz
def test_different_absolute():
    p = os.path.join('..', 'baz.py')
    assert maybe_relative_path(p) == p
def test_not_absolute():
    assert maybe_relative_path('foo/bar') == 'foo/bar'
    assert maybe_relative_path('test_platform.py') == 'test_platform.py'
def test_absolute_mapping():
    p = os.path.abspath('baz.py')
    assert maybe_relative_path(p) == 'baz.py'
    foobaz = os.path.join('foo', 'baz.py')
    assert maybe_relative_path(os.path.abspath(foobaz)) == foobaz
예제 #11
0
def test_not_absolute():
    assert maybe_relative_path("foo/bar") == "foo/bar"
    assert maybe_relative_path("test_platform.py") == "test_platform.py"
예제 #12
0
def test_absolute_mapping():
    p = os.path.abspath("baz.py")
    assert maybe_relative_path(p) == "baz.py"
    foobaz = os.path.join("foo", "baz.py")
    assert maybe_relative_path(os.path.abspath(foobaz)) == foobaz
예제 #13
0
def test_different_absolute():
    p = os.path.join("..", "baz.py")
    assert maybe_relative_path(p) == p