test_semicolon_split.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import platform
  2. import pytest
  3. from numpy.testing import IS_64BIT
  4. from . import util
  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. )
  10. @pytest.mark.skipif(
  11. not IS_64BIT, reason="32-bit builds are buggy"
  12. )
  13. class TestMultiline(util.F2PyTest):
  14. suffix = ".pyf"
  15. module_name = "multiline"
  16. code = f"""
  17. python module {module_name}
  18. usercode '''
  19. void foo(int* x) {{
  20. char dummy = ';';
  21. *x = 42;
  22. }}
  23. '''
  24. interface
  25. subroutine foo(x)
  26. intent(c) foo
  27. integer intent(out) :: x
  28. end subroutine foo
  29. end interface
  30. end python module {module_name}
  31. """
  32. def test_multiline(self):
  33. assert self.module.foo() == 42
  34. @pytest.mark.skipif(
  35. platform.system() == "Darwin",
  36. reason="Prone to error when run with numpy/f2py/tests on mac os, "
  37. "but not when run in isolation",
  38. )
  39. @pytest.mark.skipif(
  40. not IS_64BIT, reason="32-bit builds are buggy"
  41. )
  42. @pytest.mark.slow
  43. class TestCallstatement(util.F2PyTest):
  44. suffix = ".pyf"
  45. module_name = "callstatement"
  46. code = f"""
  47. python module {module_name}
  48. usercode '''
  49. void foo(int* x) {{
  50. }}
  51. '''
  52. interface
  53. subroutine foo(x)
  54. intent(c) foo
  55. integer intent(out) :: x
  56. callprotoargument int*
  57. callstatement {{ &
  58. ; &
  59. x = 42; &
  60. }}
  61. end subroutine foo
  62. end interface
  63. end python module {module_name}
  64. """
  65. def test_callstatement(self):
  66. assert self.module.foo() == 42