diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 020e22f5df..54584dfc0f 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -720,6 +720,7 @@ RUN(NAME symbolics_12 LABELS cpython_sym c_sym llvm_sym NOFAST) RUN(NAME symbolics_13 LABELS cpython_sym c_sym llvm_sym NOFAST) RUN(NAME symbolics_14 LABELS cpython_sym llvm_sym NOFAST) RUN(NAME test_gruntz LABELS cpython_sym c_sym llvm_sym NOFAST) +RUN(NAME symbolics_15 LABELS c_sym llvm_sym NOFAST) RUN(NAME sizeof_01 LABELS llvm c EXTRAFILES sizeof_01b.c) diff --git a/integration_tests/symbolics_15.py b/integration_tests/symbolics_15.py new file mode 100644 index 0000000000..83a58b6b97 --- /dev/null +++ b/integration_tests/symbolics_15.py @@ -0,0 +1,73 @@ +from lpython import ccall, CPtr, p_c_pointer, pointer, i64, empty_c_void_p, Out +import os + +@ccall(header="symengine/cwrapper.h", c_shared_lib="symengine", c_shared_lib_path=f"{os.environ['CONDA_PREFIX']}/lib") +def basic_new_stack(x: CPtr) -> None: + pass + +@ccall(header="symengine/cwrapper.h", c_shared_lib="symengine", c_shared_lib_path=f"{os.environ['CONDA_PREFIX']}/lib") +def basic_new_heap() -> CPtr: + pass + +@ccall(header="symengine/cwrapper.h", c_shared_lib="symengine", c_shared_lib_path=f"{os.environ['CONDA_PREFIX']}/lib") +def basic_const_pi(x: CPtr) -> None: + pass + +@ccall(header="symengine/cwrapper.h", c_shared_lib="symengine", c_shared_lib_path=f"{os.environ['CONDA_PREFIX']}/lib") +def basic_assign(x: CPtr, y:CPtr) -> None: + pass + +@ccall(header="symengine/cwrapper.h", c_shared_lib="symengine", c_shared_lib_path=f"{os.environ['CONDA_PREFIX']}/lib") +def basic_str(x: CPtr) -> str: + pass + +@ccall(header="symengine/cwrapper.h", c_shared_lib="symengine", c_shared_lib_path=f"{os.environ['CONDA_PREFIX']}/lib") +def basic_free_stack(x: CPtr) -> None: + pass + +def mmrv(r: Out[list[CPtr]]) -> None: + # x: S = pi + _x: i64 = i64(0) + x: CPtr = empty_c_void_p() + p_c_pointer(pointer(_x, i64), x) + basic_new_stack(x) + basic_const_pi(x) + + # l1: list[S] + l1: list[CPtr] = [] + + # l1 = [x] + i: i32 = 0 + Len: i32 = 1 + for i in range(Len): + tmp: CPtr = basic_new_heap() + l1.append(tmp) + basic_assign(l1[0], x) + + # print(l1[0]) + s1: str = basic_str(l1[0]) + print(s1) + assert s1 == "pi" + + # r = l1 + r = l1 + + basic_free_stack(x) + +def test_mrv(): + # ans : list[S] + # temp : list[S] + ans: list[CPtr] = [] + temp: list[CPtr] = [] + + # mmrv(ans) + # temp = ans + mmrv(ans) + temp = ans + + # print(temp[0]) + s2: str = basic_str(temp[0]) + print(s2) + assert s2 == "pi" + +test_mrv() \ No newline at end of file