diff options
| author | Eli Zaretskii | 2016-09-24 13:00:40 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2016-09-24 13:00:40 +0300 |
| commit | ef5c799c661dae1d1eb52c45d7a82e93f92b47c0 (patch) | |
| tree | 7d0816ed462441f400a9ef8b8be59597aa74a43b | |
| parent | 4e71b5b343c92fc587c666b98440cd8d9b36980c (diff) | |
| download | emacs-ef5c799c661dae1d1eb52c45d7a82e93f92b47c0.tar.gz emacs-ef5c799c661dae1d1eb52c45d7a82e93f92b47c0.zip | |
Incorporate occur-tests in replace-tests
* test/lisp/replace-tests.el: Add tests from
test/lisp/legacy/occur-tests.el.
* test/lisp/legacy/occur-tests.el: File deleted.
| -rw-r--r-- | test/lisp/legacy/occur-tests.el | 352 | ||||
| -rw-r--r-- | test/lisp/replace-tests.el | 328 |
2 files changed, 327 insertions, 353 deletions
diff --git a/test/lisp/legacy/occur-tests.el b/test/lisp/legacy/occur-tests.el deleted file mode 100644 index da45d5f6502..00000000000 --- a/test/lisp/legacy/occur-tests.el +++ /dev/null | |||
| @@ -1,352 +0,0 @@ | |||
| 1 | ;;; occur-tests.el --- Test suite for occur. | ||
| 2 | |||
| 3 | ;; Copyright (C) 2010-2016 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Juri Linkov <juri@jurta.org> | ||
| 6 | ;; Keywords: matching, internal | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Code: | ||
| 24 | |||
| 25 | (require 'ert) | ||
| 26 | |||
| 27 | (defconst occur-tests | ||
| 28 | '( | ||
| 29 | ;; * Test one-line matches (at bob, eob, bol, eol). | ||
| 30 | ("x" 0 "\ | ||
| 31 | xa | ||
| 32 | b | ||
| 33 | cx | ||
| 34 | xd | ||
| 35 | xex | ||
| 36 | fx | ||
| 37 | " "\ | ||
| 38 | 6 matches in 5 lines for \"x\" in buffer: *test-occur* | ||
| 39 | 1:xa | ||
| 40 | 3:cx | ||
| 41 | 4:xd | ||
| 42 | 5:xex | ||
| 43 | 6:fx | ||
| 44 | ") | ||
| 45 | ;; * Test multi-line matches, this is the first test from | ||
| 46 | ;; http://lists.gnu.org/archive/html/emacs-devel/2005-06/msg01008.html | ||
| 47 | ;; where numbers are replaced with letters. | ||
| 48 | ("a\na" 0 "\ | ||
| 49 | a | ||
| 50 | a | ||
| 51 | a | ||
| 52 | a | ||
| 53 | a | ||
| 54 | " "\ | ||
| 55 | 2 matches for \"a\na\" in buffer: *test-occur* | ||
| 56 | 1:a | ||
| 57 | :a | ||
| 58 | 3:a | ||
| 59 | :a | ||
| 60 | ") | ||
| 61 | ;; * Test multi-line matches, this is the second test from | ||
| 62 | ;; http://lists.gnu.org/archive/html/emacs-devel/2005-06/msg01008.html | ||
| 63 | ;; where numbers are replaced with letters. | ||
| 64 | ("a\nb" 0 "\ | ||
| 65 | a | ||
| 66 | b | ||
| 67 | c | ||
| 68 | a | ||
| 69 | b | ||
| 70 | " "\ | ||
| 71 | 2 matches for \"a\nb\" in buffer: *test-occur* | ||
| 72 | 1:a | ||
| 73 | :b | ||
| 74 | 4:a | ||
| 75 | :b | ||
| 76 | ") | ||
| 77 | ;; * Test line numbers for multi-line matches with empty last match line. | ||
| 78 | ("a\n" 0 "\ | ||
| 79 | a | ||
| 80 | |||
| 81 | c | ||
| 82 | a | ||
| 83 | |||
| 84 | " "\ | ||
| 85 | 2 matches for \"a\n\" in buffer: *test-occur* | ||
| 86 | 1:a | ||
| 87 | : | ||
| 88 | 4:a | ||
| 89 | : | ||
| 90 | ") | ||
| 91 | ;; * Test multi-line matches with 3 match lines. | ||
| 92 | ("x\n.x\n" 0 "\ | ||
| 93 | ax | ||
| 94 | bx | ||
| 95 | c | ||
| 96 | d | ||
| 97 | ex | ||
| 98 | fx | ||
| 99 | " "\ | ||
| 100 | 2 matches for \"x\n.x\n\" in buffer: *test-occur* | ||
| 101 | 1:ax | ||
| 102 | :bx | ||
| 103 | :c | ||
| 104 | 5:ex | ||
| 105 | :fx | ||
| 106 | : | ||
| 107 | ") | ||
| 108 | ;; * Test non-overlapping context lines with matches at bob/eob. | ||
| 109 | ("x" 1 "\ | ||
| 110 | ax | ||
| 111 | b | ||
| 112 | c | ||
| 113 | d | ||
| 114 | ex | ||
| 115 | f | ||
| 116 | g | ||
| 117 | hx | ||
| 118 | " "\ | ||
| 119 | 3 matches for \"x\" in buffer: *test-occur* | ||
| 120 | 1:ax | ||
| 121 | :b | ||
| 122 | ------- | ||
| 123 | :d | ||
| 124 | 5:ex | ||
| 125 | :f | ||
| 126 | ------- | ||
| 127 | :g | ||
| 128 | 8:hx | ||
| 129 | ") | ||
| 130 | ;; * Test non-overlapping context lines with matches not at bob/eob. | ||
| 131 | ("x" 1 "\ | ||
| 132 | a | ||
| 133 | bx | ||
| 134 | c | ||
| 135 | d | ||
| 136 | ex | ||
| 137 | f | ||
| 138 | " "\ | ||
| 139 | 2 matches for \"x\" in buffer: *test-occur* | ||
| 140 | :a | ||
| 141 | 2:bx | ||
| 142 | :c | ||
| 143 | ------- | ||
| 144 | :d | ||
| 145 | 5:ex | ||
| 146 | :f | ||
| 147 | ") | ||
| 148 | ;; * Test overlapping context lines with matches at bob/eob. | ||
| 149 | ("x" 2 "\ | ||
| 150 | ax | ||
| 151 | bx | ||
| 152 | c | ||
| 153 | dx | ||
| 154 | e | ||
| 155 | f | ||
| 156 | gx | ||
| 157 | h | ||
| 158 | i | ||
| 159 | j | ||
| 160 | kx | ||
| 161 | " "\ | ||
| 162 | 5 matches for \"x\" in buffer: *test-occur* | ||
| 163 | 1:ax | ||
| 164 | 2:bx | ||
| 165 | :c | ||
| 166 | 4:dx | ||
| 167 | :e | ||
| 168 | :f | ||
| 169 | 7:gx | ||
| 170 | :h | ||
| 171 | :i | ||
| 172 | :j | ||
| 173 | 11:kx | ||
| 174 | ") | ||
| 175 | ;; * Test overlapping context lines with matches not at bob/eob. | ||
| 176 | ("x" 2 "\ | ||
| 177 | a | ||
| 178 | b | ||
| 179 | cx | ||
| 180 | d | ||
| 181 | e | ||
| 182 | f | ||
| 183 | gx | ||
| 184 | h | ||
| 185 | i | ||
| 186 | " "\ | ||
| 187 | 2 matches for \"x\" in buffer: *test-occur* | ||
| 188 | :a | ||
| 189 | :b | ||
| 190 | 3:cx | ||
| 191 | :d | ||
| 192 | :e | ||
| 193 | :f | ||
| 194 | 7:gx | ||
| 195 | :h | ||
| 196 | :i | ||
| 197 | ") | ||
| 198 | ;; * Test overlapping context lines with empty first and last line.. | ||
| 199 | ("x" 2 "\ | ||
| 200 | |||
| 201 | b | ||
| 202 | cx | ||
| 203 | d | ||
| 204 | e | ||
| 205 | f | ||
| 206 | gx | ||
| 207 | h | ||
| 208 | |||
| 209 | " "\ | ||
| 210 | 2 matches for \"x\" in buffer: *test-occur* | ||
| 211 | : | ||
| 212 | :b | ||
| 213 | 3:cx | ||
| 214 | :d | ||
| 215 | :e | ||
| 216 | :f | ||
| 217 | 7:gx | ||
| 218 | :h | ||
| 219 | : | ||
| 220 | ") | ||
| 221 | ;; * Test multi-line overlapping context lines. | ||
| 222 | ("x\n.x" 2 "\ | ||
| 223 | ax | ||
| 224 | bx | ||
| 225 | c | ||
| 226 | d | ||
| 227 | ex | ||
| 228 | fx | ||
| 229 | g | ||
| 230 | h | ||
| 231 | i | ||
| 232 | jx | ||
| 233 | kx | ||
| 234 | " "\ | ||
| 235 | 3 matches for \"x\n.x\" in buffer: *test-occur* | ||
| 236 | 1:ax | ||
| 237 | :bx | ||
| 238 | :c | ||
| 239 | :d | ||
| 240 | 5:ex | ||
| 241 | :fx | ||
| 242 | :g | ||
| 243 | :h | ||
| 244 | :i | ||
| 245 | 10:jx | ||
| 246 | :kx | ||
| 247 | ") | ||
| 248 | ;; * Test multi-line non-overlapping context lines. | ||
| 249 | ("x\n.x" 2 "\ | ||
| 250 | ax | ||
| 251 | bx | ||
| 252 | c | ||
| 253 | d | ||
| 254 | e | ||
| 255 | f | ||
| 256 | gx | ||
| 257 | hx | ||
| 258 | " "\ | ||
| 259 | 2 matches for \"x\n.x\" in buffer: *test-occur* | ||
| 260 | 1:ax | ||
| 261 | :bx | ||
| 262 | :c | ||
| 263 | :d | ||
| 264 | ------- | ||
| 265 | :e | ||
| 266 | :f | ||
| 267 | 7:gx | ||
| 268 | :hx | ||
| 269 | ") | ||
| 270 | ;; * Test non-overlapping negative (before-context) lines. | ||
| 271 | ("x" -2 "\ | ||
| 272 | a | ||
| 273 | bx | ||
| 274 | c | ||
| 275 | d | ||
| 276 | e | ||
| 277 | fx | ||
| 278 | g | ||
| 279 | h | ||
| 280 | ix | ||
| 281 | " "\ | ||
| 282 | 3 matches for \"x\" in buffer: *test-occur* | ||
| 283 | :a | ||
| 284 | 2:bx | ||
| 285 | ------- | ||
| 286 | :d | ||
| 287 | :e | ||
| 288 | 6:fx | ||
| 289 | ------- | ||
| 290 | :g | ||
| 291 | :h | ||
| 292 | 9:ix | ||
| 293 | ") | ||
| 294 | ;; * Test overlapping negative (before-context) lines. | ||
| 295 | ("x" -3 "\ | ||
| 296 | a | ||
| 297 | bx | ||
| 298 | c | ||
| 299 | dx | ||
| 300 | e | ||
| 301 | f | ||
| 302 | gx | ||
| 303 | h | ||
| 304 | " "\ | ||
| 305 | 3 matches for \"x\" in buffer: *test-occur* | ||
| 306 | :a | ||
| 307 | 2:bx | ||
| 308 | :c | ||
| 309 | 4:dx | ||
| 310 | :e | ||
| 311 | :f | ||
| 312 | 7:gx | ||
| 313 | ") | ||
| 314 | |||
| 315 | ) | ||
| 316 | "List of tests for `occur'. | ||
| 317 | Each element has the format: | ||
| 318 | \(REGEXP NLINES INPUT-BUFFER-STRING OUTPUT-BUFFER-STRING).") | ||
| 319 | |||
| 320 | (defun occur-test-case (test) | ||
| 321 | (let ((regexp (nth 0 test)) | ||
| 322 | (nlines (nth 1 test)) | ||
| 323 | (input-buffer-string (nth 2 test)) | ||
| 324 | (temp-buffer (get-buffer-create " *test-occur*"))) | ||
| 325 | (unwind-protect | ||
| 326 | (save-window-excursion | ||
| 327 | (with-current-buffer temp-buffer | ||
| 328 | (erase-buffer) | ||
| 329 | (insert input-buffer-string) | ||
| 330 | (occur regexp nlines) | ||
| 331 | (with-current-buffer "*Occur*" | ||
| 332 | (buffer-substring-no-properties (point-min) (point-max))))) | ||
| 333 | (and (buffer-name temp-buffer) | ||
| 334 | (kill-buffer temp-buffer))))) | ||
| 335 | |||
| 336 | (defun occur-test-create (n) | ||
| 337 | "Create a test for element N of the `occur-tests' constant." | ||
| 338 | (let ((testname (intern (format "occur-test-%.2d" n))) | ||
| 339 | (testdoc (format "Test element %d of `occur-tests'." n))) | ||
| 340 | (eval | ||
| 341 | `(ert-deftest ,testname () | ||
| 342 | ,testdoc | ||
| 343 | (let (occur-hook) | ||
| 344 | (should (equal (occur-test-case (nth ,n occur-tests)) | ||
| 345 | (nth 3 (nth ,n occur-tests))))))))) | ||
| 346 | |||
| 347 | (dotimes (i (length occur-tests)) | ||
| 348 | (occur-test-create i)) | ||
| 349 | |||
| 350 | (provide 'occur-tests) | ||
| 351 | |||
| 352 | ;;; occur-tests.el ends here | ||
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el index bfaab6c8944..2b71348f350 100644 --- a/test/lisp/replace-tests.el +++ b/test/lisp/replace-tests.el | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | ;;; replace-tests.el --- tests for replace.el. | 1 | ;;; replace-tests.el --- tests for replace.el. |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2015-2016 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2010-2016 Free Software Foundation, Inc. |
| 4 | |||
| 5 | ;; Author: Nicolas Richard <youngfrog@members.fsf.org> | ||
| 6 | ;; Author: Juri Linkov <juri@jurta.org> | ||
| 4 | 7 | ||
| 5 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 6 | 9 | ||
| @@ -32,4 +35,327 @@ | |||
| 32 | (query-replace--split-string (concat before "\0" after)) | 35 | (query-replace--split-string (concat before "\0" after)) |
| 33 | (concat before "\0" after))))))) | 36 | (concat before "\0" after))))))) |
| 34 | 37 | ||
| 38 | (defconst replace-occur-tests | ||
| 39 | '( | ||
| 40 | ;; * Test one-line matches (at bob, eob, bol, eol). | ||
| 41 | ("x" 0 "\ | ||
| 42 | xa | ||
| 43 | b | ||
| 44 | cx | ||
| 45 | xd | ||
| 46 | xex | ||
| 47 | fx | ||
| 48 | " "\ | ||
| 49 | 6 matches in 5 lines for \"x\" in buffer: *test-occur* | ||
| 50 | 1:xa | ||
| 51 | 3:cx | ||
| 52 | 4:xd | ||
| 53 | 5:xex | ||
| 54 | 6:fx | ||
| 55 | ") | ||
| 56 | ;; * Test multi-line matches, this is the first test from | ||
| 57 | ;; http://lists.gnu.org/archive/html/emacs-devel/2005-06/msg01008.html | ||
| 58 | ;; where numbers are replaced with letters. | ||
| 59 | ("a\na" 0 "\ | ||
| 60 | a | ||
| 61 | a | ||
| 62 | a | ||
| 63 | a | ||
| 64 | a | ||
| 65 | " "\ | ||
| 66 | 2 matches for \"a\na\" in buffer: *test-occur* | ||
| 67 | 1:a | ||
| 68 | :a | ||
| 69 | 3:a | ||
| 70 | :a | ||
| 71 | ") | ||
| 72 | ;; * Test multi-line matches, this is the second test from | ||
| 73 | ;; http://lists.gnu.org/archive/html/emacs-devel/2005-06/msg01008.html | ||
| 74 | ;; where numbers are replaced with letters. | ||
| 75 | ("a\nb" 0 "\ | ||
| 76 | a | ||
| 77 | b | ||
| 78 | c | ||
| 79 | a | ||
| 80 | b | ||
| 81 | " "\ | ||
| 82 | 2 matches for \"a\nb\" in buffer: *test-occur* | ||
| 83 | 1:a | ||
| 84 | :b | ||
| 85 | 4:a | ||
| 86 | :b | ||
| 87 | ") | ||
| 88 | ;; * Test line numbers for multi-line matches with empty last match line. | ||
| 89 | ("a\n" 0 "\ | ||
| 90 | a | ||
| 91 | |||
| 92 | c | ||
| 93 | a | ||
| 94 | |||
| 95 | " "\ | ||
| 96 | 2 matches for \"a\n\" in buffer: *test-occur* | ||
| 97 | 1:a | ||
| 98 | : | ||
| 99 | 4:a | ||
| 100 | : | ||
| 101 | ") | ||
| 102 | ;; * Test multi-line matches with 3 match lines. | ||
| 103 | ("x\n.x\n" 0 "\ | ||
| 104 | ax | ||
| 105 | bx | ||
| 106 | c | ||
| 107 | d | ||
| 108 | ex | ||
| 109 | fx | ||
| 110 | " "\ | ||
| 111 | 2 matches for \"x\n.x\n\" in buffer: *test-occur* | ||
| 112 | 1:ax | ||
| 113 | :bx | ||
| 114 | :c | ||
| 115 | 5:ex | ||
| 116 | :fx | ||
| 117 | : | ||
| 118 | ") | ||
| 119 | ;; * Test non-overlapping context lines with matches at bob/eob. | ||
| 120 | ("x" 1 "\ | ||
| 121 | ax | ||
| 122 | b | ||
| 123 | c | ||
| 124 | d | ||
| 125 | ex | ||
| 126 | f | ||
| 127 | g | ||
| 128 | hx | ||
| 129 | " "\ | ||
| 130 | 3 matches for \"x\" in buffer: *test-occur* | ||
| 131 | 1:ax | ||
| 132 | :b | ||
| 133 | ------- | ||
| 134 | :d | ||
| 135 | 5:ex | ||
| 136 | :f | ||
| 137 | ------- | ||
| 138 | :g | ||
| 139 | 8:hx | ||
| 140 | ") | ||
| 141 | ;; * Test non-overlapping context lines with matches not at bob/eob. | ||
| 142 | ("x" 1 "\ | ||
| 143 | a | ||
| 144 | bx | ||
| 145 | c | ||
| 146 | d | ||
| 147 | ex | ||
| 148 | f | ||
| 149 | " "\ | ||
| 150 | 2 matches for \"x\" in buffer: *test-occur* | ||
| 151 | :a | ||
| 152 | 2:bx | ||
| 153 | :c | ||
| 154 | ------- | ||
| 155 | :d | ||
| 156 | 5:ex | ||
| 157 | :f | ||
| 158 | ") | ||
| 159 | ;; * Test overlapping context lines with matches at bob/eob. | ||
| 160 | ("x" 2 "\ | ||
| 161 | ax | ||
| 162 | bx | ||
| 163 | c | ||
| 164 | dx | ||
| 165 | e | ||
| 166 | f | ||
| 167 | gx | ||
| 168 | h | ||
| 169 | i | ||
| 170 | j | ||
| 171 | kx | ||
| 172 | " "\ | ||
| 173 | 5 matches for \"x\" in buffer: *test-occur* | ||
| 174 | 1:ax | ||
| 175 | 2:bx | ||
| 176 | :c | ||
| 177 | 4:dx | ||
| 178 | :e | ||
| 179 | :f | ||
| 180 | 7:gx | ||
| 181 | :h | ||
| 182 | :i | ||
| 183 | :j | ||
| 184 | 11:kx | ||
| 185 | ") | ||
| 186 | ;; * Test overlapping context lines with matches not at bob/eob. | ||
| 187 | ("x" 2 "\ | ||
| 188 | a | ||
| 189 | b | ||
| 190 | cx | ||
| 191 | d | ||
| 192 | e | ||
| 193 | f | ||
| 194 | gx | ||
| 195 | h | ||
| 196 | i | ||
| 197 | " "\ | ||
| 198 | 2 matches for \"x\" in buffer: *test-occur* | ||
| 199 | :a | ||
| 200 | :b | ||
| 201 | 3:cx | ||
| 202 | :d | ||
| 203 | :e | ||
| 204 | :f | ||
| 205 | 7:gx | ||
| 206 | :h | ||
| 207 | :i | ||
| 208 | ") | ||
| 209 | ;; * Test overlapping context lines with empty first and last line.. | ||
| 210 | ("x" 2 "\ | ||
| 211 | |||
| 212 | b | ||
| 213 | cx | ||
| 214 | d | ||
| 215 | e | ||
| 216 | f | ||
| 217 | gx | ||
| 218 | h | ||
| 219 | |||
| 220 | " "\ | ||
| 221 | 2 matches for \"x\" in buffer: *test-occur* | ||
| 222 | : | ||
| 223 | :b | ||
| 224 | 3:cx | ||
| 225 | :d | ||
| 226 | :e | ||
| 227 | :f | ||
| 228 | 7:gx | ||
| 229 | :h | ||
| 230 | : | ||
| 231 | ") | ||
| 232 | ;; * Test multi-line overlapping context lines. | ||
| 233 | ("x\n.x" 2 "\ | ||
| 234 | ax | ||
| 235 | bx | ||
| 236 | c | ||
| 237 | d | ||
| 238 | ex | ||
| 239 | fx | ||
| 240 | g | ||
| 241 | h | ||
| 242 | i | ||
| 243 | jx | ||
| 244 | kx | ||
| 245 | " "\ | ||
| 246 | 3 matches for \"x\n.x\" in buffer: *test-occur* | ||
| 247 | 1:ax | ||
| 248 | :bx | ||
| 249 | :c | ||
| 250 | :d | ||
| 251 | 5:ex | ||
| 252 | :fx | ||
| 253 | :g | ||
| 254 | :h | ||
| 255 | :i | ||
| 256 | 10:jx | ||
| 257 | :kx | ||
| 258 | ") | ||
| 259 | ;; * Test multi-line non-overlapping context lines. | ||
| 260 | ("x\n.x" 2 "\ | ||
| 261 | ax | ||
| 262 | bx | ||
| 263 | c | ||
| 264 | d | ||
| 265 | e | ||
| 266 | f | ||
| 267 | gx | ||
| 268 | hx | ||
| 269 | " "\ | ||
| 270 | 2 matches for \"x\n.x\" in buffer: *test-occur* | ||
| 271 | 1:ax | ||
| 272 | :bx | ||
| 273 | :c | ||
| 274 | :d | ||
| 275 | ------- | ||
| 276 | :e | ||
| 277 | :f | ||
| 278 | 7:gx | ||
| 279 | :hx | ||
| 280 | ") | ||
| 281 | ;; * Test non-overlapping negative (before-context) lines. | ||
| 282 | ("x" -2 "\ | ||
| 283 | a | ||
| 284 | bx | ||
| 285 | c | ||
| 286 | d | ||
| 287 | e | ||
| 288 | fx | ||
| 289 | g | ||
| 290 | h | ||
| 291 | ix | ||
| 292 | " "\ | ||
| 293 | 3 matches for \"x\" in buffer: *test-occur* | ||
| 294 | :a | ||
| 295 | 2:bx | ||
| 296 | ------- | ||
| 297 | :d | ||
| 298 | :e | ||
| 299 | 6:fx | ||
| 300 | ------- | ||
| 301 | :g | ||
| 302 | :h | ||
| 303 | 9:ix | ||
| 304 | ") | ||
| 305 | ;; * Test overlapping negative (before-context) lines. | ||
| 306 | ("x" -3 "\ | ||
| 307 | a | ||
| 308 | bx | ||
| 309 | c | ||
| 310 | dx | ||
| 311 | e | ||
| 312 | f | ||
| 313 | gx | ||
| 314 | h | ||
| 315 | " "\ | ||
| 316 | 3 matches for \"x\" in buffer: *test-occur* | ||
| 317 | :a | ||
| 318 | 2:bx | ||
| 319 | :c | ||
| 320 | 4:dx | ||
| 321 | :e | ||
| 322 | :f | ||
| 323 | 7:gx | ||
| 324 | ") | ||
| 325 | |||
| 326 | ) | ||
| 327 | "List of tests for `occur'. | ||
| 328 | Each element has the format: | ||
| 329 | \(REGEXP NLINES INPUT-BUFFER-STRING OUTPUT-BUFFER-STRING).") | ||
| 330 | |||
| 331 | (defun replace-occur-test-case (test) | ||
| 332 | (let ((regexp (nth 0 test)) | ||
| 333 | (nlines (nth 1 test)) | ||
| 334 | (input-buffer-string (nth 2 test)) | ||
| 335 | (temp-buffer (get-buffer-create " *test-occur*"))) | ||
| 336 | (unwind-protect | ||
| 337 | (save-window-excursion | ||
| 338 | (with-current-buffer temp-buffer | ||
| 339 | (erase-buffer) | ||
| 340 | (insert input-buffer-string) | ||
| 341 | (occur regexp nlines) | ||
| 342 | (with-current-buffer "*Occur*" | ||
| 343 | (buffer-substring-no-properties (point-min) (point-max))))) | ||
| 344 | (and (buffer-name temp-buffer) | ||
| 345 | (kill-buffer temp-buffer))))) | ||
| 346 | |||
| 347 | (defun replace-occur-test-create (n) | ||
| 348 | "Create a test for element N of the `replace-occur-tests' constant." | ||
| 349 | (let ((testname (intern (format "occur-test-%.2d" n))) | ||
| 350 | (testdoc (format "Test element %d of `replace-occur-tests'." n))) | ||
| 351 | (eval | ||
| 352 | `(ert-deftest ,testname () | ||
| 353 | ,testdoc | ||
| 354 | (let (replace-occur-hook) | ||
| 355 | (should (equal (replace-occur-test-case (nth ,n replace-occur-tests)) | ||
| 356 | (nth 3 (nth ,n replace-occur-tests))))))))) | ||
| 357 | |||
| 358 | (dotimes (i (length replace-occur-tests)) | ||
| 359 | (replace-occur-test-create i)) | ||
| 360 | |||
| 35 | ;;; replace-tests.el ends here | 361 | ;;; replace-tests.el ends here |