Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Smit-create committed Jul 25, 2023
1 parent d16420a commit 46dd897
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,10 @@ RUN(NAME callback_01 LABELS cpython llvm c)
RUN(NAME callback_02 LABELS cpython llvm c)
RUN(NAME callback_03 LABELS cpython llvm c)


# callback_04 is to test emulation. So just run with cpython
RUN(NAME callback_04 IMPORT_PATH .. LABELS cpython)

# Intrinsic Functions
RUN(NAME intrinsics_01 LABELS cpython llvm NOFAST) # any

Expand Down
18 changes: 18 additions & 0 deletions integration_tests/callback_04.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import lpython
from lpython import i32
from types import FunctionType
import callback_04_module

lpython.CTypes.emulations = {k: v for k, v in callback_04_module.__dict__.items()
if isinstance(v, FunctionType)}


def foo(x : i32) -> i32:
assert x == 3
print(x)
return x

def entry_point() -> None:
callback_04_module.bar(foo, 3)

entry_point()
4 changes: 4 additions & 0 deletions integration_tests/callback_04_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from lpython import i32, Callable

def bar(func : Callable[[i32], i32], arg : i32) -> i32:
return func(arg)

0 comments on commit 46dd897

Please sign in to comment.