Commit | Line | Data |
---|---|---|
21fedf28 GM |
1 | ;;; f90.el --- tests for progmodes/f90.el |
2 | ||
acaf905b | 3 | ;; Copyright (C) 2011-2012 Free Software Foundation, Inc. |
21fedf28 GM |
4 | |
5 | ;; Author: Glenn Morris <rgm@gnu.org> | |
6 | ||
7 | ;; This file is part of GNU Emacs. | |
8 | ||
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. | |
13 | ||
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. | |
18 | ||
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/>. | |
21 | ||
22 | ;;; Commentary: | |
23 | ||
24 | ;; This file does not have "test" in the name, because it lives under | |
25 | ;; a test/ directory, so that would be superfluous. | |
26 | ||
27 | ;;; Code: | |
28 | ||
29 | (require 'ert) | |
30 | (require 'f90) | |
31 | ||
32 | (defconst f90-test-indent "\ | |
33 | !! Comment before code. | |
34 | !!! Comments before code. | |
35 | #preprocessor before code | |
36 | ||
37 | program progname | |
38 | ||
39 | implicit none | |
40 | ||
41 | integer :: i | |
42 | ||
43 | !! Comment. | |
44 | ||
45 | do i = 1, 10 | |
46 | ||
47 | #preprocessor | |
48 | ||
49 | !! Comment. | |
50 | if ( i % 2 == 0 ) then | |
51 | !! Comment. | |
52 | cycle | |
53 | else | |
54 | write(*,*) i | |
55 | end if | |
56 | end do | |
57 | ||
58 | !!! Comment. | |
59 | ||
60 | end program progname | |
61 | " | |
62 | "Test string for F90 indentation.") | |
63 | ||
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)))) | |
72 | ||
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 | |
79 | ||
80 | include \"file.f90\" | |
81 | ||
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))))) | |
91 | ||
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))))))) | |
103 | ||
104 | ;; TODO bug#5593 | |
105 | ||
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))))) | |
118 | ||
119 | ;; TODO bug#8812 | |
120 | ||
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 "."))))) | |
126 | ||
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))))))) | |
137 | ||
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))))))) | |
148 | ||
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))))) | |
156 | ||
a0099d31 GM |
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 | |
164 | & 1 | |
165 | #else | |
166 | & 2 | |
167 | #endif | |
168 | ||
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))))) | |
21fedf28 GM |
175 | |
176 | ;;; f90.el ends here |