gnu.emacs/test/lisp/outline-tests.el
Roi Martin e33b54d938 Rename outline-xref' command to outline-find-headings'
* etc/NEWS: Update entry.
* lisp/outline.el (outline-mode-prefix-map, outline-mode-menu-bar-map):
Use `outline-find-headings'.
(outline-find-headings--fetch-xrefs): Rename from
`outline-xref--fetch-headings'.
(outline-find-headings--show-xrefs): Rename from
`outline-xref--show-xrefs'.
(outline-find-headings): Rename from `outline-xref'.
* test/lisp/outline-tests.el
(outline-tests--outline-find-headings-search-function): Rename from
`outline-tests--outline-xref-search-function'.
(outline-tests--outline-find-headings-regexp): Rename from
`outline-tests--outline-xref-regexp'.
(outline-tests--outline-find-headings-undefined): Rename from
`outline-tests--outline-xref-undefined'.  (Bug#81592)
2026-09-08 05:36:42 +03:00

72 lines
2.6 KiB
EmacsLisp

;;; outline-tests.el --- ERT tests for outline.el -*- lexical-binding: t -*-
;; Copyright (C) 2026 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Tests for the `outline' feature.
;;; Code:
(require 'ert)
(require 'ert-x)
(require 'outline)
(ert-deftest outline-tests--outline-find-headings-search-function ()
"Test the `outline-find-headings' function with `outline-search-function'."
(let ((test-file (ert-resource-file "outline.txt")))
(with-temp-buffer
(insert-file-contents test-file)
(let ((outline-regexp "\\*")
(outline-search-function
(lambda (&optional bound move _backward _looking-at)
(re-search-forward "^-" bound move))))
(outline-find-headings)))
(with-current-buffer (get-buffer "*xref*")
(goto-char (point-min))
(should-error (search-forward "* Star heading"))
(goto-char (point-min))
(should (search-forward "- Dash heading")))))
(ert-deftest outline-tests--outline-find-headings-regexp ()
"Test the `outline-find-headings' function with `outline-regexp'."
(let ((test-file (ert-resource-file "outline.txt")))
(with-temp-buffer
(insert-file-contents test-file)
(let ((outline-regexp "\\*")
(outline-search-function nil))
(outline-find-headings)))
(with-current-buffer (get-buffer "*xref*")
(goto-char (point-min))
(should (search-forward "* Star heading"))
(goto-char (point-min))
(should-error (search-forward "- Dash heading")))))
(ert-deftest outline-tests--outline-find-headings-undefined ()
"Test the `outline-find-headings' function with undefined search strategy."
(let ((test-file (ert-resource-file "outline.txt")))
(with-temp-buffer
(insert-file-contents test-file)
(let ((outline-regexp nil)
(outline-search-function nil))
(should-error (outline-find-headings))))))
(provide 'outline-tests)
;;; outline-tests.el ends here