aboutsummaryrefslogtreecommitdiffstats
path: root/test/src/undo-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/undo-tests.el')
-rw-r--r--test/src/undo-tests.el55
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 @@
1;;; undo-tests.el --- Tests of primitive-undo 1;;; undo-tests.el --- Tests of primitive-undo -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2012-2017 Free Software Foundation, Inc. 3;; Copyright (C) 2012-2022 Free Software Foundation, Inc.
4 4
5;; Author: Aaron S. Hawley <aaron.s.hawley@gmail.com> 5;; Author: Aaron S. Hawley <aaron.s.hawley@gmail.com>
6 6
7;; This program is free software: you can redistribute it and/or 7;; This file is part of GNU Emacs.
8;;
9;; GNU Emacs is free software: you can redistribute it and/or
8;; modify it under the terms of the GNU General Public License as 10;; modify it under the terms of the GNU General Public License as
9;; published by the Free Software Foundation, either version 3 of the 11;; published by the Free Software Foundation, either version 3 of the
10;; License, or (at your option) any later version. 12;; License, or (at your option) any later version.
11;; 13;;
12;; This program is distributed in the hope that it will be useful, but 14;; GNU Emacs is distributed in the hope that it will be useful, but
13;; WITHOUT ANY WARRANTY; without even the implied warranty of 15;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15;; General Public License for more details. 17;; General Public License for more details.
16;; 18;;
17;; You should have received a copy of the GNU General Public License 19;; You should have received a copy of the GNU General Public License
18;; along with this program. If not, see `https://www.gnu.org/licenses/'. 20;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19 21
20;;; Commentary: 22;;; Commentary:
21 23
@@ -44,6 +46,8 @@
44;;; Code: 46;;; Code:
45 47
46(require 'ert) 48(require 'ert)
49(require 'ert-x)
50(require 'facemenu)
47 51
48(ert-deftest undo-test0 () 52(ert-deftest undo-test0 ()
49 "Test basics of \\[undo]." 53 "Test basics of \\[undo]."
@@ -72,7 +76,7 @@
72 (undo-boundary) 76 (undo-boundary)
73 (put-text-property (point-min) (point-max) 'face 'bold) 77 (put-text-property (point-min) (point-max) 'face 'bold)
74 (undo-boundary) 78 (undo-boundary)
75 (remove-text-properties (point-min) (point-max) '(face default)) 79 (remove-list-of-text-properties (point-min) (point-max) '(face))
76 (undo-boundary) 80 (undo-boundary)
77 (set-buffer-multibyte (not enable-multibyte-characters)) 81 (set-buffer-multibyte (not enable-multibyte-characters))
78 (undo-boundary) 82 (undo-boundary)
@@ -85,6 +89,7 @@
85 89
86(ert-deftest undo-test1 () 90(ert-deftest undo-test1 ()
87 "Test undo of \\[undo] command (redo)." 91 "Test undo of \\[undo] command (redo)."
92 (require 'facemenu)
88 (with-temp-buffer 93 (with-temp-buffer
89 (buffer-enable-undo) 94 (buffer-enable-undo)
90 (undo-boundary) 95 (undo-boundary)
@@ -214,17 +219,14 @@
214 219
215(ert-deftest undo-test-file-modified () 220(ert-deftest undo-test-file-modified ()
216 "Test undoing marks buffer visiting file unmodified." 221 "Test undoing marks buffer visiting file unmodified."
217 (let ((tempfile (make-temp-file "undo-test"))) 222 (ert-with-temp-file tempfile
218 (unwind-protect 223 (with-current-buffer (find-file-noselect tempfile)
219 (progn 224 (insert "1")
220 (with-current-buffer (find-file-noselect tempfile) 225 (undo-boundary)
221 (insert "1") 226 (set-buffer-modified-p nil)
222 (undo-boundary) 227 (insert "2")
223 (set-buffer-modified-p nil) 228 (undo)
224 (insert "2") 229 (should-not (buffer-modified-p)))))
225 (undo)
226 (should-not (buffer-modified-p))))
227 (delete-file tempfile))))
228 230
229(ert-deftest undo-test-region-not-most-recent () 231(ert-deftest undo-test-region-not-most-recent ()
230 "Test undo in region of an edit not the most recent." 232 "Test undo in region of an edit not the most recent."
@@ -255,7 +257,7 @@
255 (insert "12345") 257 (insert "12345")
256 (search-backward "4") 258 (search-backward "4")
257 (undo-boundary) 259 (undo-boundary)
258 (delete-forward-char 1) 260 (funcall-interactively 'delete-forward-char 1)
259 (search-backward "1") 261 (search-backward "1")
260 (undo-boundary) 262 (undo-boundary)
261 (insert "xxxx") 263 (insert "xxxx")
@@ -299,7 +301,7 @@ undo-make-selective-list."
299 (insert "ddd") 301 (insert "ddd")
300 (search-backward "ad") 302 (search-backward "ad")
301 (undo-boundary) 303 (undo-boundary)
302 (delete-forward-char 2) 304 (funcall-interactively 'delete-forward-char 2)
303 (undo-boundary) 305 (undo-boundary)
304 ;; Select "dd" 306 ;; Select "dd"
305 (push-mark (point) t t) 307 (push-mark (point) t t)
@@ -348,7 +350,7 @@ undo-make-selective-list."
348 (let ((m (make-marker))) 350 (let ((m (make-marker)))
349 (set-marker m 2 (current-buffer)) 351 (set-marker m 2 (current-buffer))
350 (goto-char (point-min)) 352 (goto-char (point-min))
351 (delete-forward-char 3) 353 (funcall-interactively 'delete-forward-char 3)
352 (undo-boundary) 354 (undo-boundary)
353 (should (= (point-min) (marker-position m))) 355 (should (= (point-min) (marker-position m)))
354 (undo) 356 (undo)
@@ -369,7 +371,7 @@ undo-make-selective-list."
369 (push-mark (point) t t) 371 (push-mark (point) t t)
370 (setq mark-active t) 372 (setq mark-active t)
371 (goto-char (point-min)) 373 (goto-char (point-min))
372 (delete-forward-char 1) ;; delete region covering "ab" 374 (funcall-interactively 'delete-forward-char 1) ; delete region covering "ab"
373 (undo-boundary) 375 (undo-boundary)
374 (should (= (point-min) (marker-position m))) 376 (should (= (point-min) (marker-position m)))
375 ;; Resurrect "ab". m's insertion type means the reinsertion 377 ;; Resurrect "ab". m's insertion type means the reinsertion
@@ -389,7 +391,7 @@ Demonstrates bug 16818."
389 (let ((m (make-marker))) 391 (let ((m (make-marker)))
390 (set-marker m 2 (current-buffer)) ; m at b 392 (set-marker m 2 (current-buffer)) ; m at b
391 (goto-char (point-min)) 393 (goto-char (point-min))
392 (delete-forward-char 3) ; m at d 394 (funcall-interactively 'delete-forward-char 3) ; m at d
393 (undo-boundary) 395 (undo-boundary)
394 (set-marker m 4) ; m at g 396 (set-marker m 4) ; m at g
395 (undo) 397 (undo)
@@ -422,7 +424,7 @@ Demonstrates bug 16818."
422 (push-mark (point) t t) 424 (push-mark (point) t t)
423 (setq mark-active t) 425 (setq mark-active t)
424 (goto-char (- (point) 3)) 426 (goto-char (- (point) 3))
425 (delete-forward-char 1) 427 (funcall-interactively 'delete-forward-char 1)
426 (undo-boundary) 428 (undo-boundary)
427 429
428 (insert "bbb") 430 (insert "bbb")
@@ -452,17 +454,16 @@ Demonstrates bug 25599."
452 (insert ";; aaaaaaaaa 454 (insert ";; aaaaaaaaa
453;; bbbbbbbb") 455;; bbbbbbbb")
454 (let ((overlay-modified 456 (let ((overlay-modified
455 (lambda (ov after-p _beg _end &optional length) 457 (lambda (ov after-p _beg _end &optional _length)
456 (unless after-p 458 (unless after-p
457 (when (overlay-buffer ov) 459 (when (overlay-buffer ov)
458 (delete-overlay ov)))))) 460 (delete-overlay ov))))))
459 (save-excursion 461 (save-excursion
460 (goto-char (point-min)) 462 (goto-char (point-min))
461 (let ((ov (make-overlay (line-beginning-position 2) 463 (let ((ov (make-overlay (pos-bol 2) (pos-eol 2))))
462 (line-end-position 2))))
463 (overlay-put ov 'insert-in-front-hooks 464 (overlay-put ov 'insert-in-front-hooks
464 (list overlay-modified))))) 465 (list overlay-modified)))))
465 (kill-region (point-min) (line-beginning-position 2)) 466 (kill-region (point-min) (pos-bol 2))
466 (undo-boundary) 467 (undo-boundary)
467 (undo))) 468 (undo)))
468 469