| 25 | |
| 26 | |
| 27 | class TestDocAdvanced(util.F2PyTest): |
| 28 | # options = ['--debug-capi', '--build-dir', '/tmp/build-f2py'] |
| 29 | sources = [_path('asterisk1.f90'), _path('asterisk2.f90'), |
| 30 | _path('ftype.f')] |
| 31 | |
| 32 | def test_asterisk1(self): |
| 33 | foo = getattr(self.module, 'foo1') |
| 34 | assert_equal(foo(), b'123456789A12') |
| 35 | |
| 36 | def test_asterisk2(self): |
| 37 | foo = getattr(self.module, 'foo2') |
| 38 | assert_equal(foo(2), b'12') |
| 39 | assert_equal(foo(12), b'123456789A12') |
| 40 | assert_equal(foo(24), b'123456789A123456789B') |
| 41 | |
| 42 | def test_ftype(self): |
| 43 | ftype = self.module |
| 44 | ftype.foo() |
| 45 | assert_equal(ftype.data.a, 0) |
| 46 | ftype.data.a = 3 |
| 47 | ftype.data.x = [1, 2, 3] |
| 48 | assert_equal(ftype.data.a, 3) |
| 49 | assert_array_equal(ftype.data.x, |
| 50 | np.array([1, 2, 3], dtype=np.float32)) |
| 51 | ftype.data.x[1] = 45 |
| 52 | assert_array_equal(ftype.data.x, |
| 53 | np.array([1, 45, 3], dtype=np.float32)) |
| 54 | |
| 55 | # TODO: implement test methods for other example Fortran codes |