aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lisp/replace-tests.el42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el
index f5cff92d546..aed14c33572 100644
--- a/test/lisp/replace-tests.el
+++ b/test/lisp/replace-tests.el
@@ -546,4 +546,46 @@ Return the last evalled form in BODY."
546 ?q 546 ?q
547 (string= expected (buffer-string)))))) 547 (string= expected (buffer-string))))))
548 548
549(defmacro replace-tests-with-highlighted-occurrence (highlight-locus &rest body)
550 "Helper macro to test the highlight of matches when navigating occur buffer.
551
552Eval BODY with `next-error-highlight' and `next-error-highlight-no-select'
553bound to HIGHLIGHT-LOCUS."
554 (declare (indent 1) (debug (form body)))
555 `(let ((regexp "foo")
556 (next-error-highlight ,highlight-locus)
557 (next-error-highlight-no-select ,highlight-locus)
558 (buffer (generate-new-buffer "test"))
559 (inhibit-message t))
560 (unwind-protect
561 ;; Local bind to disable the deletion of `occur-highlight-overlay'
562 (cl-letf (((symbol-function 'occur-goto-locus-delete-o) (lambda ())))
563 (with-current-buffer buffer (dotimes (_ 3) (insert regexp ?\n)))
564 (pop-to-buffer buffer)
565 (occur regexp)
566 (pop-to-buffer "*Occur*")
567 (occur-next)
568 ,@body)
569 (kill-buffer buffer)
570 (kill-buffer "*Occur*"))))
571
572(ert-deftest occur-highlight-occurrence ()
573 "Test for https://debbugs.gnu.org/39121 ."
574 (let ((alist '((nil . nil) (0.5 . t) (t . t) (fringe-arrow . nil)))
575 (check-overlays
576 (lambda (has-ov)
577 (eq has-ov (not (null (overlays-in (point-min) (point-max))))))))
578 (pcase-dolist (`(,highlight-locus . ,has-overlay) alist)
579 ;; Visiting occurrences
580 (replace-tests-with-highlighted-occurrence highlight-locus
581 (occur-mode-goto-occurrence)
582 (should (funcall check-overlays has-overlay)))
583 ;; Displaying occurrences
584 (replace-tests-with-highlighted-occurrence highlight-locus
585 (occur-mode-display-occurrence)
586 (with-current-buffer (marker-buffer
587 (get-text-property (point) 'occur-target))
588 (should (funcall check-overlays has-overlay)))))))
589
590
549;;; replace-tests.el ends here 591;;; replace-tests.el ends here