Exemple #1
0
 def test_include_1(self):
     from re_py_subsrc import ffi
     assert ffi.integer_const('FOOBAR') == -42
     assert ffi.integer_const('FOOBAZ') == -43
     assert ffi.integer_const('k2') == 121212
     lib = ffi.dlopen(self.extmod)     # <- a random unrelated library would be fine
     assert lib.FOOBAR == -42
     assert lib.FOOBAZ == -43
     assert lib.k2 == 121212
     #
     p = ffi.new("bar_t *", [5, b"foobar"])
     assert p.a[4] == ord('a')
Exemple #2
0
 def test_include_1(self):
     self.fix_path()
     from re_py_subsrc import ffi
     assert ffi.integer_const('FOOBAR') == -42
     assert ffi.integer_const('FOOBAZ') == -43
     assert ffi.integer_const('k2') == 121212
     lib = ffi.dlopen(self.extmod)     # <- a random unrelated library would be fine
     assert lib.FOOBAR == -42
     assert lib.FOOBAZ == -43
     assert lib.k2 == 121212
     #
     p = ffi.new("bar_t *", [5, b"foobar"])
     assert p.a[4] == ord('a')
Exemple #3
0
def test_include_1():
    sub_ffi = FFI()
    sub_ffi.cdef("static const int k2 = 121212;")
    sub_ffi.include(original_ffi)
    assert 'macro FOOBAR' in original_ffi._parser._declarations
    assert 'macro FOOBAZ' in original_ffi._parser._declarations
    sub_ffi.set_source('re_python_pysrc', None)
    sub_ffi.emit_python_code(str(tmpdir.join('_re_include_1.py')))
    #
    if sys.version_info[:2] >= (3, 3):
        import importlib
        importlib.invalidate_caches()  # issue 197 (but can't reproduce myself)
    #
    from _re_include_1 import ffi
    assert ffi.integer_const('FOOBAR') == -42
    assert ffi.integer_const('FOOBAZ') == -43
    assert ffi.integer_const('k2') == 121212
    lib = ffi.dlopen(extmod)     # <- a random unrelated library would be fine
    assert lib.FOOBAR == -42
    assert lib.FOOBAZ == -43
    assert lib.k2 == 121212
    #
    p = ffi.new("bar_t *", [5, b"foobar"])
    assert p.a[4] == ord('a')
Exemple #4
0
def test_large_constant():
    from re_python_pysrc import ffi
    assert ffi.integer_const('BIGPOS') == 420000000000
    assert ffi.integer_const('BIGNEG') == -420000000000
Exemple #5
0
def test_constant():
    from re_python_pysrc import ffi
    assert ffi.integer_const('FOOBAR') == -42
    assert ffi.integer_const('FOOBAZ') == -43
Exemple #6
0
def test_enum():
    from re_python_pysrc import ffi
    assert ffi.integer_const("BB") == 1
    e = ffi.cast("enum foo_e", 2)
    assert ffi.string(e) == "CC"
Exemple #7
0
 def test_large_constant(self):
     self.fix_path()
     from re_python_pysrc import ffi
     assert ffi.integer_const('BIGPOS') == 420000000000
     assert ffi.integer_const('BIGNEG') == -420000000000
Exemple #8
0
 def test_constant_1(self):
     self.fix_path()
     from re_python_pysrc import ffi
     assert ffi.integer_const('FOOBAR') == -42
     assert ffi.integer_const('FOOBAZ') == -43
Exemple #9
0
    def test_constant_1(self):
        from re_python_pysrc import ffi

        assert ffi.integer_const("FOOBAR") == -42
        assert ffi.integer_const("FOOBAZ") == -43
Exemple #10
0
    def test_large_constant(self):
        from re_python_pysrc import ffi

        assert ffi.integer_const("BIGPOS") == 420000000000
        assert ffi.integer_const("BIGNEG") == -420000000000