Skip to content

Commit 8042526

Browse files
committed
TST: add test case described in ticket 9228 for numpy.f2py
1 parent dc063ad commit 8042526

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
SUBROUTINE INITCB
2+
DOUBLE PRECISION LONG
3+
CHARACTER STRING
4+
INTEGER OK
5+
6+
COMMON /BLOCK/ LONG, STRING, OK
7+
LONG = 1.0
8+
STRING = '2'
9+
OK = 3
10+
RETURN
11+
END

numpy/f2py/tests/test_common.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from __future__ import division, absolute_import, print_function
2+
3+
import os
4+
5+
from numpy.testing import run_module_suite, assert_array_equal, dec
6+
import numpy as np
7+
import util
8+
9+
10+
def _path(*a):
11+
return os.path.join(*((os.path.dirname(__file__),) + a))
12+
13+
class TestCommonBlock(util.F2PyTest):
14+
sources = [_path('src', 'common', 'block.f')]
15+
16+
def test_common_block(self):
17+
self.module.initcb()
18+
assert_array_equal(self.module.block.long_bn,
19+
np.array(1.0, dtype=np.float64))
20+
assert_array_equal(self.module.block.string_bn,
21+
np.array('2', dtype='|S1'))
22+
assert_array_equal(self.module.block.ok,
23+
np.array(3, dtype=np.int32))
24+
25+
if __name__ == "__main__":
26+
run_module_suite()

0 commit comments

Comments
 (0)