From 4c302ef9890d9a5c84841a42e39a658166f39e2e Mon Sep 17 00:00:00 2001 From: anutosh491 Date: Fri, 21 Jul 2023 16:03:34 +0530 Subject: [PATCH 1/2] Added tests based on basic_new_stack function --- integration_tests/CMakeLists.txt | 1 + integration_tests/symbolics_08.py | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 integration_tests/symbolics_08.py diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 7e2be504a5..a81b2df96e 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -646,6 +646,7 @@ RUN(NAME symbolics_04 LABELS cpython_sym c_sym) RUN(NAME symbolics_05 LABELS cpython_sym c_sym) RUN(NAME symbolics_06 LABELS cpython_sym c_sym) RUN(NAME symbolics_07 LABELS cpython_sym c_sym llvm_sym NOFAST) +RUN(NAME symbolics_08 LABELS c_sym llvm_sym) RUN(NAME sizeof_01 LABELS llvm c EXTRAFILES sizeof_01b.c) diff --git a/integration_tests/symbolics_08.py b/integration_tests/symbolics_08.py new file mode 100644 index 0000000000..82b664acf6 --- /dev/null +++ b/integration_tests/symbolics_08.py @@ -0,0 +1,26 @@ +from lpython import ccall, CPtr, p_c_pointer, pointer, i64, empty_c_void_p +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_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_str(x: CPtr) -> str: + pass + +def main0(): + y: i64 = i64(0) + x: CPtr = empty_c_void_p() + p_c_pointer(pointer(y), x) + basic_new_stack(x) + basic_const_pi(x) + s: str = basic_str(x) + print(s) + assert s == "pi" + +main0() \ No newline at end of file From b87a25ba799eef97455137f26d3d685c8d272372 Mon Sep 17 00:00:00 2001 From: anutosh491 Date: Fri, 21 Jul 2023 16:10:09 +0530 Subject: [PATCH 2/2] added support for cpython_sym backend --- integration_tests/CMakeLists.txt | 2 +- integration_tests/symbolics_08.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index a81b2df96e..d05382962f 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -646,7 +646,7 @@ RUN(NAME symbolics_04 LABELS cpython_sym c_sym) RUN(NAME symbolics_05 LABELS cpython_sym c_sym) RUN(NAME symbolics_06 LABELS cpython_sym c_sym) RUN(NAME symbolics_07 LABELS cpython_sym c_sym llvm_sym NOFAST) -RUN(NAME symbolics_08 LABELS c_sym llvm_sym) +RUN(NAME symbolics_08 LABELS cpython_sym c_sym llvm_sym) RUN(NAME sizeof_01 LABELS llvm c EXTRAFILES sizeof_01b.c) diff --git a/integration_tests/symbolics_08.py b/integration_tests/symbolics_08.py index 82b664acf6..c360b60f37 100644 --- a/integration_tests/symbolics_08.py +++ b/integration_tests/symbolics_08.py @@ -16,7 +16,7 @@ def basic_str(x: CPtr) -> str: def main0(): y: i64 = i64(0) x: CPtr = empty_c_void_p() - p_c_pointer(pointer(y), x) + p_c_pointer(pointer(y, i64), x) basic_new_stack(x) basic_const_pi(x) s: str = basic_str(x)