test_semicolon_split.py 1.5 KB

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