diff --git a/tests/gh55.f90 b/tests/gh55.f90 new file mode 100644 index 0000000..99b59b2 --- /dev/null +++ b/tests/gh55.f90 @@ -0,0 +1,30 @@ + + +! SPDX-License-Identifier: GPL-2.0+ + +module gh55 + + use iso_fortran_env, only: output_unit, real128 + + implicit none + + ! Parameters + integer, parameter :: dp = selected_real_kind(p=15) + integer, parameter :: qp = selected_real_kind(p=30) + integer, parameter :: lp = selected_int_kind(16) + + + contains + + recursive function return_char(x) result(str) + integer, intent(in) :: x + character(len=10), dimension((2 ** x - 1) ) :: str + + str = '' + str(2**x-1) = 'abcdefghil' + + end function return_char + +end module gh55 + + diff --git a/tests/gh55_test.py b/tests/gh55_test.py new file mode 100644 index 0000000..066b2d6 --- /dev/null +++ b/tests/gh55_test.py @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-2.0+ + +import os, sys +import ctypes +from pprint import pprint + +os.environ["_GFORT2PY_TEST_FLAG"] = "1" + +import numpy as np +import gfort2py as gf + +import pytest + +SO = f"./tests/gh55.{gf.lib_ext()}" +MOD = "./tests/gh55.mod" + +x = gf.fFort(SO, MOD) + + +@pytest.mark.skip("Currently broken needs array descriptor for strings") +class Testgh55Methods: + def test_func_str_return_array(self): + + size = 3 + res = x.return_char(size) + + return_str = res.result + + assert np.size(np.shape(return_str)) == ((2**size) - 1) + assert return_str[-1] == "abcdefghij" diff --git a/tests/make_new_test_case.py b/tests/make_new_test_case.py index bbbeb3f..a6956e3 100755 --- a/tests/make_new_test_case.py +++ b/tests/make_new_test_case.py @@ -23,7 +23,7 @@ def make_test_case(name): SO = f"./tests/{name}.{{gf.lib_ext()}}" MOD = "./tests/{name}.mod" -x=gf.fFort(SO,MOD) +x = gf.fFort(SO,MOD) class Test{name}Methods: diff --git a/tests/strings_test.py b/tests/strings_test.py index cfe279e..05e7b44 100644 --- a/tests/strings_test.py +++ b/tests/strings_test.py @@ -309,29 +309,3 @@ def test_check_str_opt(self): res = x.check_str_opt("abcd", 4) assert res.result == 4 - - @pytest.mark.skip("Currently under development") - def test_func_str_return_array(self): - fstr = """ - - recursive function return_char(x) result(str) - implicit none - integer, intent(in) :: x - character(len=10), dimension((2 ** x - 1) ) :: str - - str = '' - str(2**x-1) = 'abcdefghil' - - end function return_char - - """ - - size = 2 - z = gf.compile(fstr) - - res = z.return_char(size) - - return_str = res.result - - assert np.size(np.shape(return_str)) == ((2**size) - 1) - assert return_str[-1] == "abcdefghij"