pypy / pypy / translator / c / test / test_dlltool.py

from pypy.translator.c.dlltool import DLLDef
from ctypes import CDLL
import py

class TestDLLTool(object):
    def test_basic(self):
        # XXX abusing get_entry_point to get a so name makes no sense
        def f(x):
            return x

        def b(x):
            return x + 2

        d = DLLDef('lib', [(f, [int]), (b, [int])])
        so = d.compile()
        dll = CDLL(str(so))
        assert dll.pypy_g_f(3) == 3
        assert dll.pypy_g_b(10) == 12

    def test_split_criteria(self):
        def f(x):
            return x

        def b(x):
            return x + 2

        d = DLLDef('lib', [(f, [int]), (b, [int])])
        so = d.compile()
        dirpath = py.path.local(so).dirpath()
        assert dirpath.join('translator_c_test_test_dlltool.c').check()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.