summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjutke <jutke@allstate.com>2017-01-20 09:55:13 -0600
committerCharles Harris <charlesr.harris@gmail.com>2017-01-28 18:44:19 -0700
commit70c82bf8fa5acd56022ff9c20ac19873ead9f80c (patch)
tree0958f738e52a8a925fa95a3da491ef06948224fa
parent2dd299311d55298ce1e26c4073f0aa5728ad5554 (diff)
downloadnumpy-70c82bf8fa5acd56022ff9c20ac19873ead9f80c.tar.gz
TST: adding tests for compound constant provided by @zerothi
This is a test code provided as a patch by @zerothi checking the compound constant parsing.
-rw-r--r--numpy/f2py/tests/src/parameter/constant_compound.f9015
-rw-r--r--numpy/f2py/tests/test_parameter.py12
2 files changed, 27 insertions, 0 deletions
diff --git a/numpy/f2py/tests/src/parameter/constant_compound.f90 b/numpy/f2py/tests/src/parameter/constant_compound.f90
new file mode 100644
index 000000000..e51f5e9b2
--- /dev/null
+++ b/numpy/f2py/tests/src/parameter/constant_compound.f90
@@ -0,0 +1,15 @@
+! Check that parameters are correct intercepted.
+! Constants with comma separations are commonly
+! used, for instance Pi = 3._dp
+subroutine foo_compound_int(x)
+ implicit none
+ integer, parameter :: ii = selected_int_kind(9)
+ integer(ii), intent(inout) :: x
+ dimension x(3)
+ integer(ii), parameter :: three = 3_ii
+ integer(ii), parameter :: two = 2_ii
+ integer(ii), parameter :: six = three * 1_ii * two
+
+ x(1) = x(1) + x(2) + x(3) * six
+ return
+end subroutine
diff --git a/numpy/f2py/tests/test_parameter.py b/numpy/f2py/tests/test_parameter.py
index f0168b2d5..e7c6add51 100644
--- a/numpy/f2py/tests/test_parameter.py
+++ b/numpy/f2py/tests/test_parameter.py
@@ -18,6 +18,7 @@ class TestParameters(util.F2PyTest):
sources = [_path('src', 'parameter', 'constant_real.f90'),
_path('src', 'parameter', 'constant_integer.f90'),
_path('src', 'parameter', 'constant_both.f90'),
+ _path('src', 'parameter', 'constant_compound.f90'),
]
@dec.slow
@@ -43,6 +44,17 @@ class TestParameters(util.F2PyTest):
assert_equal(x, [0 + 1 + 2*3, 1, 2])
@dec.slow
+ def test_constant_compound_int(self):
+ # non-contiguous should raise error
+ x = np.arange(6, dtype=np.int32)[::2]
+ assert_raises(ValueError, self.module.foo_compound_int, x)
+
+ # check values with contiguous array
+ x = np.arange(3, dtype=np.int32)
+ self.module.foo_compound_int(x)
+ assert_equal(x, [0 + 1 + 2*6, 1, 2])
+
+ @dec.slow
def test_constant_integer_int(self):
# non-contiguous should raise error
x = np.arange(6, dtype=np.int32)[::2]