From 19184646d32b8bf1bcf0ad118da9a51fe271501a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Thu, 10 Aug 2023 17:39:59 +0200 Subject: [PATCH] Add low-level Julia test --- CMakeLists.txt | 8 ++++++++ test/julia/lowlevel_test.jl | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 test/julia/lowlevel_test.jl diff --git a/CMakeLists.txt b/CMakeLists.txt index 694812d3c2..fac3331b87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -652,6 +652,14 @@ if(openPMD_HAVE_JULIA) POSITION_INDEPENDENT_CODE ON WINDOWS_EXPORT_ALL_SYMBOLS ON ) + + add_test(NAME CLI.julia_lowlevel + COMMAND julia + ${openPMD_SOURCE_DIR}/test/julia/lowlevel_test.jl + ${openPMD_LIBRARY_OUTPUT_DIRECTORY}/libopenPMD.jl.so + WORKING_DIRECTORY + ${openPMD_RUNTIME_OUTPUT_DIRECTORY} + ) endif() # python bindings diff --git a/test/julia/lowlevel_test.jl b/test/julia/lowlevel_test.jl new file mode 100644 index 0000000000..7d4e5922e1 --- /dev/null +++ b/test/julia/lowlevel_test.jl @@ -0,0 +1,35 @@ +import Base + +# pass as first argument the path to libopenPMD.jl.so + +module openPMD +using CxxWrap +@wrapmodule(ARGS[1]) + +function __init__() + @initcxx +end +end + +s = openPMD.CXX_Series( + "../samples/lowlevel_julia_test.json", openPMD.ACCESS_CREATE) + +function Base.getindex( + cont::Cont, + index, +) where +{ + A, + B, + Cont<:openPMD.CXX_Container{A,B} +} + return openPMD.cxx_getindex(cont, index) +end + +iteration = openPMD.cxx_iterations(s)[100] +mesh = openPMD.cxx_meshes(iteration) +# empty brackets to dereference CxxRef +# automatic dereferencing works only for Int types since CxxRwap.jl defines +# Base.getindex(x::CxxBaseRef, i::Int) = Base.getindex(x[], i) +mesh[]["E"][]["x"] +openPMD.cxx_flush(s, "{}")