Skip to content

Commit f5efa48

Browse files
committed
Add tests
1 parent 7991557 commit f5efa48

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

integration_tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,9 @@ RUN(NAME global_syms_06 LABELS cpython llvm c)
723723
RUN(NAME callback_01 LABELS cpython llvm c)
724724
RUN(NAME callback_02 LABELS cpython llvm c)
725725

726+
# callback_03 is to test emulation. So just run with cpython
727+
RUN(NAME callback_03 IMPORT_PATH .. LABELS cpython)
728+
726729
# Intrinsic Functions
727730
RUN(NAME intrinsics_01 LABELS cpython llvm NOFAST) # any
728731

integration_tests/callback_03.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)