test-ob-fortran.el 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ;;; test-ob-fortran.el --- tests for ob-fortran.el -*- lexical-binding: t; -*-
  2. ;; Copyright (c) 2010-2014, 2019 Sergey Litvinov
  3. ;; Authors: Sergey Litvinov
  4. ;; This file is not part of GNU Emacs.
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. ;;; Code:
  16. (org-test-for-executable "gfortran")
  17. (unless (featurep 'ob-fortran)
  18. (signal 'missing-test-dependency "Support for Fortran code blocks"))
  19. (ert-deftest ob-fortran/assert ()
  20. (should t))
  21. (ert-deftest ob-fortran/simple-program ()
  22. "Test of hello world program."
  23. (org-test-at-id "459384e8-1797-4f11-867e-dde0473ea7cc"
  24. (org-babel-next-src-block)
  25. (should (equal "Hello world" (org-babel-execute-src-block)))))
  26. (ert-deftest ob-fortran/fortran-var-program ()
  27. "Test a fortran variable"
  28. (org-test-at-id "459384e8-1797-4f11-867e-dde0473ea7cc"
  29. (org-babel-next-src-block 2)
  30. (should (= 10 (org-babel-execute-src-block)))))
  31. (ert-deftest ob-fortran/input-var ()
  32. "Test :var"
  33. (org-test-at-id "d8d1dfd3-5f0c-48fe-b55d-777997e02242"
  34. (org-babel-next-src-block)
  35. (should (= 15 (org-babel-execute-src-block)))))
  36. (ert-deftest ob-fortran/preprocessor-var ()
  37. "Test preprocessed fortran"
  38. (org-test-at-id "d8d1dfd3-5f0c-48fe-b55d-777997e02242"
  39. (org-babel-next-src-block 2)
  40. (should (= 42 (org-babel-execute-src-block)))))
  41. (ert-deftest ob-fortran/character-var ()
  42. "Test string input"
  43. (org-test-at-id "d8d1dfd3-5f0c-48fe-b55d-777997e02242"
  44. (org-babel-next-src-block 3)
  45. (should (equal "word" (org-babel-execute-src-block)))))
  46. (ert-deftest ob-fortran/list-var ()
  47. "Test real array input"
  48. (org-test-at-id "c28569d9-04ce-4cad-ab81-1ea29f691465"
  49. (org-babel-next-src-block)
  50. (should (equal "1.00 2.00 3.00" (org-babel-execute-src-block)))))
  51. (ert-deftest ob-fortran/list-var-from-table ()
  52. "Test real array from a table"
  53. (org-test-at-id "c28569d9-04ce-4cad-ab81-1ea29f691465"
  54. (org-babel-next-src-block 2)
  55. (should (equal "1.00 2.00" (org-babel-execute-src-block)))))
  56. (ert-deftest ob-fortran/list-matrix-from-table1 ()
  57. "Test real matrix from a table"
  58. (org-test-at-id "3f73ab19-d25a-428d-8c26-e8c6aa933976"
  59. (org-babel-next-src-block 1)
  60. (should (= 42 (org-babel-execute-src-block)))))
  61. (ert-deftest ob-fortran/list-matrix-from-table2 ()
  62. "Test real matrix from a table"
  63. (org-test-at-id "3f73ab19-d25a-428d-8c26-e8c6aa933976"
  64. (org-babel-next-src-block 2)
  65. (should (= 42 (org-babel-execute-src-block)))))
  66. (ert-deftest ob-fortran/no-variables-with-main ()
  67. "Test :var with explicit 'program'"
  68. (org-test-at-id "891ead4a-f87a-473c-9ae0-1cf348bcd04f"
  69. (org-babel-next-src-block)
  70. (should-error (org-babel-execute-src-block))
  71. :type 'error))
  72. ;; (ert-deftest ob-fortran/wrong-list ()
  73. ;; "Test wrong input list"
  74. ;; (org-test-at-id "891ead4a-f87a-473c-9ae0-1cf348bcd04f"
  75. ;; (org-babel-next-src-block 2)
  76. ;; (should-error (org-babel-execute-src-block))
  77. ;; :type 'error))
  78. ;; (ert-deftest ob-fortran/compiler-flags ()
  79. ;; "Test compiler's flags"
  80. ;; (org-test-at-id "891ead4a-f87a-473c-9ae0-1cf348bcd04f"
  81. ;; (org-babel-next-src-block 3)
  82. ;; (should-error (org-babel-execute-src-block))
  83. ;; :type 'error))
  84. (ert-deftest ob-fortran/command-arguments ()
  85. "Test real array from a table"
  86. (org-test-at-id "2d5330ea-9934-4737-9ed6-e1d3dae2dfa4"
  87. (org-babel-next-src-block)
  88. (should (= 23 (org-babel-execute-src-block)))))
  89. (provide 'test-ob-fortran)
  90. ;;; test-ob-fortran.el ends here