Skip to content

Commit 0487143

Browse files
committed
Add tests
1 parent d16420a commit 0487143

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,10 @@ RUN(NAME callback_01 LABELS cpython llvm c)
724724
RUN(NAME callback_02 LABELS cpython llvm c)
725725
RUN(NAME callback_03 LABELS cpython llvm c)
726726

727+
728+
# callback_04 is to test emulation. So just run with cpython
729+
RUN(NAME callback_04 IMPORT_PATH .. LABELS cpython)
730+
727731
# Intrinsic Functions
728732
RUN(NAME intrinsics_01 LABELS cpython llvm NOFAST) # any
729733

integration_tests/callback_04.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import lpython
2+
from lpython import i32
3+
from types import FunctionType
4+
import callback_03_module
5+
6+
lpython.CTypes.emulations = {k: v for k, v in callback_03_module.__dict__.items()
7+
if isinstance(v, FunctionType)}
8+
9+
10+
def foo(x : i32) -> i32:
11+
assert x == 3
12+
print(x)
13+
return x
14+
15+
def entry_point() -> None:
16+
callback_03_module.bar(foo, 3)
17+
18+
entry_point()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from lpython import i32, Callable
2+
3+
def bar(func : Callable[[i32], i32], arg : i32) -> i32:
4+
return func(arg)

0 commit comments

Comments
 (0)