1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/usr/bin/env python
"""
Tests for module with scalar derived types and subprograms.
-----
Permission to use, modify, and distribute this software is given under the
terms of the NumPy License. See http://scipy.org.
NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
Author: Pearu Peterson <pearu@cens.ioc.ee>
Created: Oct 2006
-----
"""
import os
import sys
from numpy.testing import *
set_package_path()
from lib.main import build_extension, compile
restore_path()
fortran_code = '''
module test_module_scalar_ext
contains
subroutine foo(a)
integer a
!f2py intent(in,out) a
a = a + 1
end subroutine foo
function foo2(a)
integer a
integer foo2
foo2 = a + 2
end function foo2
end module test_module_scalar_ext
'''
m, = compile(fortran_code, modulenames = ['test_module_scalar_ext'])
from numpy import *
class TestM(NumpyTestCase):
def check_foo_simple(self, level=1):
foo = m.foo
r = foo(2)
assert isinstance(r,int32),`type(r)`
assert_equal(r,3)
def check_foo2_simple(self, level=1):
foo2 = m.foo2
r = foo2(2)
assert isinstance(r,int32),`type(r)`
assert_equal(r,4)
if __name__ == "__main__":
NumpyTest().run()
|