test_semicolon_split.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. from __future__ import division, absolute_import, print_function
  2. import platform
  3. import pytest
  4. from . import util
  5. from numpy.testing import assert_equal
  6. @pytest.mark.skipif(
  7. platform.system() == 'Darwin',
  8. reason="Prone to error when run with numpy/f2py/tests on mac os, "
  9. "but not when run in isolation")
  10. class TestMultiline(util.F2PyTest):
  11. suffix = ".pyf"
  12. module_name = "multiline"
  13. code = """
  14. python module {module}
  15. usercode '''
  16. void foo(int* x) {{
  17. char dummy = ';';
  18. *x = 42;
  19. }}
  20. '''
  21. interface
  22. subroutine foo(x)
  23. intent(c) foo
  24. integer intent(out) :: x
  25. end subroutine foo
  26. end interface
  27. end python module {module}
  28. """.format(module=module_name)
  29. def test_multiline(self):
  30. assert_equal(self.module.foo(), 42)
  31. @pytest.mark.skipif(
  32. platform.system() == 'Darwin',
  33. reason="Prone to error when run with numpy/f2py/tests on mac os, "
  34. "but not when run in isolation")
  35. class TestCallstatement(util.F2PyTest):
  36. suffix = ".pyf"
  37. module_name = "callstatement"
  38. code = """
  39. python module {module}
  40. usercode '''
  41. void foo(int* x) {{
  42. }}
  43. '''
  44. interface
  45. subroutine foo(x)
  46. intent(c) foo
  47. integer intent(out) :: x
  48. callprotoargument int*
  49. callstatement {{ &
  50. ; &
  51. x = 42; &
  52. }}
  53. end subroutine foo
  54. end interface
  55. end python module {module}
  56. """.format(module=module_name)
  57. def test_callstatement(self):
  58. assert_equal(self.module.foo(), 42)