test_semicolon_split.py 1.6 KB

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