1 ;;; f90.el --- tests for progmodes/f90.el
3 ;; Copyright (C) 2011-2015 Free Software Foundation, Inc.
5 ;; Author: Glenn Morris <rgm@gnu.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;; This file does not have "test" in the name, because it lives under
25 ;; a test/ directory, so that would be superfluous.
32 (defconst f90-test-indent
"\
33 !! Comment before code.
34 !!! Comments before code.
35 #preprocessor before code
50 if ( i % 2 == 0 ) then
62 "Test string for F90 indentation.")
64 (ert-deftest f90-test-indent
()
65 "Test F90 indentation."
68 (insert f90-test-indent
)
69 (indent-rigidly (point-min) (point-max) -
999)
70 (f90-indent-region (point-min) (point-max))
71 (should (string-equal (buffer-string) f90-test-indent
))))
73 (ert-deftest f90-test-bug3729
()
74 "Test for http://debbugs.gnu.org/3729 ."
75 :expected-result
:failed
87 (goto-char (point-min))
89 (f90-indent-subprogram)
90 (should (= 0 (current-indentation)))))
92 (ert-deftest f90-test-bug3730
()
93 "Test for http://debbugs.gnu.org/3730 ."
101 (skip-chars-forward "[ \t]")
102 (should (equal "&(/" (buffer-substring (point) (+ 3 (point)))))))
106 (ert-deftest f90-test-bug8691
()
107 "Test for http://debbugs.gnu.org/8691 ."
110 (insert "module modname
111 type, bind(c) :: type1
115 (f90-indent-subprogram)
117 (should (= 2 (current-indentation)))))
121 (ert-deftest f90-test-bug8820
()
122 "Test for http://debbugs.gnu.org/8820 ."
125 (should (eq (char-syntax ?%
) (string-to-char ".")))))
127 (ert-deftest f90-test-bug9553a
()
128 "Test for http://debbugs.gnu.org/9553 ."
132 (dotimes (_i 20) (insert " aaaa"))
135 ;; This gives a more informative failure than looking-at.
136 (should (equal "!!! a" (buffer-substring (point) (+ 5 (point)))))))
138 (ert-deftest f90-test-bug9553b
()
139 "Test for http://debbugs.gnu.org/9553 ."
143 (dotimes (_i 13) (insert " aaaa"))
147 (should (equal "!!! a" (buffer-substring (point) (+ 5 (point)))))))
149 (ert-deftest f90-test-bug9690
()
150 "Test for http://debbugs.gnu.org/9690 ."
153 (insert "#include \"foo.h\"")
155 (should (= 0 (current-indentation)))))
157 (ert-deftest f90-test-bug13138
()
158 "Test for http://debbugs.gnu.org/13138 ."
161 (insert "program prog
171 (goto-char (point-min))
173 (f90-indent-subprogram)
174 (should (= 0 (current-indentation)))))
176 (ert-deftest f90-test-bug-19809
()
177 "Test for http://debbugs.gnu.org/19809 ."
180 ;; The Fortran standard says that continued strings should have
181 ;; '&' at the start of continuation lines, but it seems gfortran
182 ;; allows them to be absent (albeit with a warning).
183 (insert "program prog
187 (goto-char (point-min))
188 (f90-end-of-subprogram)
189 (should (= (point) (point-max)))))
191 (ert-deftest f90-test-bug20680
()
192 "Test for http://debbugs.gnu.org/20680 ."
195 (insert "module modname
196 type, extends ( sometype ) :: type1
200 (f90-indent-subprogram)
202 (should (= 2 (current-indentation)))))
204 (ert-deftest f90-test-bug20680b
()
205 "Test for http://debbugs.gnu.org/20680 ."
208 (insert "module modname
213 (f90-indent-subprogram)
215 (should (= 2 (current-indentation)))))