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