diff options
Diffstat (limited to 'test/src/undo-tests.el')
-rw-r--r-- | test/src/undo-tests.el | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/test/src/undo-tests.el b/test/src/undo-tests.el index 3ff75ae68d5..cb0822fb1b9 100644 --- a/test/src/undo-tests.el +++ b/test/src/undo-tests.el @@ -1,21 +1,23 @@ -;;; undo-tests.el --- Tests of primitive-undo +;;; undo-tests.el --- Tests of primitive-undo -*- lexical-binding: t -*- -;; Copyright (C) 2012-2017 Free Software Foundation, Inc. +;; Copyright (C) 2012-2022 Free Software Foundation, Inc. ;; Author: Aaron S. Hawley <aaron.s.hawley@gmail.com> -;; This program is free software: you can redistribute it and/or +;; 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. ;; -;; This program is distributed in the hope that it will be useful, but +;; 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 this program. If not, see `https://www.gnu.org/licenses/'. +;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. ;;; Commentary: @@ -44,6 +46,8 @@ ;;; Code: (require 'ert) +(require 'ert-x) +(require 'facemenu) (ert-deftest undo-test0 () "Test basics of \\[undo]." @@ -72,7 +76,7 @@ (undo-boundary) (put-text-property (point-min) (point-max) 'face 'bold) (undo-boundary) - (remove-text-properties (point-min) (point-max) '(face default)) + (remove-list-of-text-properties (point-min) (point-max) '(face)) (undo-boundary) (set-buffer-multibyte (not enable-multibyte-characters)) (undo-boundary) @@ -85,6 +89,7 @@ (ert-deftest undo-test1 () "Test undo of \\[undo] command (redo)." + (require 'facemenu) (with-temp-buffer (buffer-enable-undo) (undo-boundary) @@ -214,17 +219,14 @@ (ert-deftest undo-test-file-modified () "Test undoing marks buffer visiting file unmodified." - (let ((tempfile (make-temp-file "undo-test"))) - (unwind-protect - (progn - (with-current-buffer (find-file-noselect tempfile) - (insert "1") - (undo-boundary) - (set-buffer-modified-p nil) - (insert "2") - (undo) - (should-not (buffer-modified-p)))) - (delete-file tempfile)))) + (ert-with-temp-file tempfile + (with-current-buffer (find-file-noselect tempfile) + (insert "1") + (undo-boundary) + (set-buffer-modified-p nil) + (insert "2") + (undo) + (should-not (buffer-modified-p))))) (ert-deftest undo-test-region-not-most-recent () "Test undo in region of an edit not the most recent." @@ -255,7 +257,7 @@ (insert "12345") (search-backward "4") (undo-boundary) - (delete-forward-char 1) + (funcall-interactively 'delete-forward-char 1) (search-backward "1") (undo-boundary) (insert "xxxx") @@ -299,7 +301,7 @@ undo-make-selective-list." (insert "ddd") (search-backward "ad") (undo-boundary) - (delete-forward-char 2) + (funcall-interactively 'delete-forward-char 2) (undo-boundary) ;; Select "dd" (push-mark (point) t t) @@ -348,7 +350,7 @@ undo-make-selective-list." (let ((m (make-marker))) (set-marker m 2 (current-buffer)) (goto-char (point-min)) - (delete-forward-char 3) + (funcall-interactively 'delete-forward-char 3) (undo-boundary) (should (= (point-min) (marker-position m))) (undo) @@ -369,7 +371,7 @@ undo-make-selective-list." (push-mark (point) t t) (setq mark-active t) (goto-char (point-min)) - (delete-forward-char 1) ;; delete region covering "ab" + (funcall-interactively 'delete-forward-char 1) ; delete region covering "ab" (undo-boundary) (should (= (point-min) (marker-position m))) ;; Resurrect "ab". m's insertion type means the reinsertion @@ -389,7 +391,7 @@ Demonstrates bug 16818." (let ((m (make-marker))) (set-marker m 2 (current-buffer)) ; m at b (goto-char (point-min)) - (delete-forward-char 3) ; m at d + (funcall-interactively 'delete-forward-char 3) ; m at d (undo-boundary) (set-marker m 4) ; m at g (undo) @@ -422,7 +424,7 @@ Demonstrates bug 16818." (push-mark (point) t t) (setq mark-active t) (goto-char (- (point) 3)) - (delete-forward-char 1) + (funcall-interactively 'delete-forward-char 1) (undo-boundary) (insert "bbb") @@ -452,17 +454,16 @@ Demonstrates bug 25599." (insert ";; aaaaaaaaa ;; bbbbbbbb") (let ((overlay-modified - (lambda (ov after-p _beg _end &optional length) + (lambda (ov after-p _beg _end &optional _length) (unless after-p (when (overlay-buffer ov) (delete-overlay ov)))))) (save-excursion (goto-char (point-min)) - (let ((ov (make-overlay (line-beginning-position 2) - (line-end-position 2)))) + (let ((ov (make-overlay (pos-bol 2) (pos-eol 2)))) (overlay-put ov 'insert-in-front-hooks (list overlay-modified))))) - (kill-region (point-min) (line-beginning-position 2)) + (kill-region (point-min) (pos-bol 2)) (undo-boundary) (undo))) |