Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / test / automated / f90.el
blobe009f84d2d2b24924dada0272679e39577df29a9
1 ;;; f90.el --- tests for progmodes/f90.el
3 ;; Copyright (C) 2011-2014 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/>.
22 ;;; Commentary:
24 ;; This file does not have "test" in the name, because it lives under
25 ;; a test/ directory, so that would be superfluous.
27 ;;; Code:
29 (require 'ert)
30 (require 'f90)
32 (defconst f90-test-indent "\
33 !! Comment before code.
34 !!! Comments before code.
35 #preprocessor before code
37 program progname
39 implicit none
41 integer :: i
43 !! Comment.
45 do i = 1, 10
47 #preprocessor
49 !! Comment.
50 if ( i % 2 == 0 ) then
51 !! Comment.
52 cycle
53 else
54 write(*,*) i
55 end if
56 end do
58 !!! Comment.
60 end program progname
62 "Test string for F90 indentation.")
64 (ert-deftest f90-test-indent ()
65 "Test F90 indentation."
66 (with-temp-buffer
67 (f90-mode)
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
76 (with-temp-buffer
77 (f90-mode)
78 (insert "!! Comment
80 include \"file.f90\"
82 subroutine test (x)
83 real x
84 x = x+1.
85 return
86 end subroutine test")
87 (goto-char (point-min))
88 (forward-line 2)
89 (f90-indent-subprogram)
90 (should (= 0 (current-indentation)))))
92 (ert-deftest f90-test-bug3730 ()
93 "Test for http://debbugs.gnu.org/3730 ."
94 (with-temp-buffer
95 (f90-mode)
96 (insert "a" )
97 (move-to-column 68 t)
98 (insert "(/ x /)")
99 (f90-do-auto-fill)
100 (beginning-of-line)
101 (skip-chars-forward "[ \t]")
102 (should (equal "&(/" (buffer-substring (point) (+ 3 (point)))))))
104 ;; TODO bug#5593
106 (ert-deftest f90-test-bug8691 ()
107 "Test for http://debbugs.gnu.org/8691 ."
108 (with-temp-buffer
109 (f90-mode)
110 (insert "module modname
111 type, bind(c) :: type1
112 integer :: part1
113 end type type1
114 end module modname")
115 (f90-indent-subprogram)
116 (forward-line -1)
117 (should (= 2 (current-indentation)))))
119 ;; TODO bug#8812
121 (ert-deftest f90-test-bug8820 ()
122 "Test for http://debbugs.gnu.org/8820 ."
123 (with-temp-buffer
124 (f90-mode)
125 (should (eq (char-syntax ?%) (string-to-char ".")))))
127 (ert-deftest f90-test-bug9553a ()
128 "Test for http://debbugs.gnu.org/9553 ."
129 (with-temp-buffer
130 (f90-mode)
131 (insert "!!!")
132 (dotimes (_i 20) (insert " aaaa"))
133 (f90-do-auto-fill)
134 (beginning-of-line)
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 ."
140 (with-temp-buffer
141 (f90-mode)
142 (insert "!!!")
143 (dotimes (_i 13) (insert " aaaa"))
144 (insert "a, aaaa")
145 (f90-do-auto-fill)
146 (beginning-of-line)
147 (should (equal "!!! a" (buffer-substring (point) (+ 5 (point)))))))
149 (ert-deftest f90-test-bug9690 ()
150 "Test for http://debbugs.gnu.org/9690 ."
151 (with-temp-buffer
152 (f90-mode)
153 (insert "#include \"foo.h\"")
154 (f90-indent-line)
155 (should (= 0 (current-indentation)))))
157 (ert-deftest f90-test-bug13138 ()
158 "Test for http://debbugs.gnu.org/13138 ."
159 (with-temp-buffer
160 (f90-mode)
161 (insert "program prog
162 integer :: i = &
163 #ifdef foo
165 #else
167 #endif
169 write(*,*) i
170 end program prog")
171 (goto-char (point-min))
172 (forward-line 2)
173 (f90-indent-subprogram)
174 (should (= 0 (current-indentation)))))
176 ;;; f90.el ends here