1 ;;; occur-testsuite.el --- Test suite for occur.
3 ;; Copyright (C) 2010-2011 Free Software Foundation, Inc.
5 ;; Author: Juri Linkov <juri@jurta.org>
6 ;; Keywords: matching, internal
8 ;; This file is part of GNU Emacs.
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.
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.
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/>.
25 ;; Type M-x test-occur RET to test the functionality of `occur'.
31 ;; * Test one-line matches (at bob, eob, bol, eol).
40 5 matches for \"x\" in buffer: *temp*
47 ;; * Test multi-line matches, this is the first test from
48 ;; http://lists.gnu.org/archive/html/emacs-devel/2005-06/msg01008.html
49 ;; where numbers are replaced with letters.
57 2 matches for \"a^Ja\" in buffer: *temp*
63 ;; * Test multi-line matches, this is the second test from
64 ;; http://lists.gnu.org/archive/html/emacs-devel/2005-06/msg01008.html
65 ;; where numbers are replaced with letters.
73 2 matches for \"a^Jb\" in buffer: *temp*
79 ;; * Test line numbers for multi-line matches with empty last match line.
87 2 matches for \"a^J\" in buffer: *temp*
93 ;; * Test multi-line matches with 3 match lines.
102 2 matches for \"x^J.x^J\" in buffer: *temp*
110 ;; * Test non-overlapping context lines with matches at bob/eob.
121 3 matches for \"x\" in buffer: *temp*
132 ;; * Test non-overlapping context lines with matches not at bob/eob.
141 2 matches for \"x\" in buffer: *temp*
150 ;; * Test overlapping context lines with matches at bob/eob.
164 5 matches for \"x\" in buffer: *temp*
177 ;; * Test overlapping context lines with matches not at bob/eob.
189 2 matches for \"x\" in buffer: *temp*
200 ;; * Test overlapping context lines with empty first and last line..
212 2 matches for \"x\" in buffer: *temp*
223 ;; * Test multi-line overlapping context lines.
237 3 matches for \"x^J.x\" in buffer: *temp*
250 ;; * Test multi-line non-overlapping context lines.
261 2 matches for \"x^J.x\" in buffer: *temp*
272 ;; * Test non-overlapping negative (before-context) lines.
284 3 matches for \"x\" in buffer: *temp*
296 ;; * Test overlapping negative (before-context) lines.
307 3 matches for \"x\" in buffer: *temp*
318 "List of tests for `occur'.
319 Each element has the format:
320 \(REGEXP NLINES INPUT-BUFFER-STRING OUTPUT-BUFFER-STRING).")
327 (dolist (test occur-tests
)
328 (let ((regexp (nth 0 test
))
329 (nlines (nth 1 test
))
330 (input-buffer-string (nth 2 test
))
331 (output-buffer-string (nth 3 test
)))
334 (insert input-buffer-string
)
335 (occur regexp nlines
)
336 (unless (equal output-buffer-string
337 (with-current-buffer "*Occur*"
339 (setq failed
(cons count failed
))))))
340 (setq count
(1+ count
)))
342 (message "FAILED TESTS: %S" (reverse failed
))
343 (message "SUCCESS"))))
345 (provide 'occur-testsuite
)
347 ;;; occur-testsuite.el ends here