emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole 8133ed63eb 1/9: Add test for hui-kill-region


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 8133ed63eb 1/9: Add test for hui-kill-region
Date: Sun, 19 Jan 2025 12:58:13 -0500 (EST)

branch: externals/hyperbole
commit 8133ed63eb918811af2fd55e6392fc628512187f
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: Mats Lidell <mats.lidell@lidells.se>

    Add test for hui-kill-region
---
 ChangeLog         |   2 +
 test/hui-tests.el | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 117 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index f483bb9441..dab3e50ed9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2025-01-09  Mats Lidell  <matsl@gnu.org>
 
+* test/hui-tests.el (hui--kill-region): Test.
+
 * test/MANIFEST: Add hycontrol-tests.el
 
 * hycontrol.el (hycontrol-framemove-direction): Quit hycontrol before
diff --git a/test/hui-tests.el b/test/hui-tests.el
index 966547a11f..9b6fae379d 100644
--- a/test/hui-tests.el
+++ b/test/hui-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <matsl@gnu.org>
 ;;
 ;; Orig-Date:    30-Jan-21 at 12:00:00
-;; Last-Mod:     13-Jul-24 at 23:42:26 by Mats Lidell
+;; Last-Mod:      9-Jan-25 at 23:03:37 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1172,6 +1172,120 @@ With point on label suggest that ibut for rename."
           (gbut:act "global"))
       (hy-delete-file-and-buffer global-but-file))))
 
+(ert-deftest hui--kill-region ()
+  "Verify `hui-kill-region'."
+  (with-temp-buffer
+    (transient-mark-mode 1)
+    (insert "123")
+    (goto-char 1)
+
+    ;; No mark set
+    (should-error (hui-kill-region) :type 'error)
+
+    (set-mark (point))
+    (hui-kill-region)
+    (should (looking-at-p "123"))
+
+    (goto-char (point-max))
+    (should (region-active-p))
+    (hui-kill-region)
+    (beginning-of-buffer)
+    (should (string= "" (buffer-string)))
+
+    (insert "123(456)789")
+    (goto-char 1)
+    (set-mark (point))
+    (goto-char 4)
+    (deactivate-mark)
+    (should-not (region-active-p))
+    (funcall-interactively 'hui-kill-region)
+    (if noninteractive
+        (should (string= "(456)789" (buffer-string)))
+      (should (string= "123789" (buffer-string))))
+
+    (delete-region (point-min) (point-max))
+    (insert "123(456)789")
+    (goto-char 1)
+    (set-mark (point))
+    (goto-char 4)
+    (should (region-active-p))
+    (funcall-interactively 'hui-kill-region)
+    (should (string= "(456)789" (buffer-string)))
+
+    (delete-region (point-min) (point-max))
+    (insert "123(456)789")
+    (goto-char 1)
+    (set-mark (point))
+    (goto-char 4)
+    (deactivate-mark)
+    (should-not (region-active-p))
+    (hui-kill-region)
+    (should (string= "(456)789" (buffer-string)))
+
+    (delete-region (point-min) (point-max))
+    (insert "123(456)789")
+    (goto-char 1)
+    (set-mark (point))
+    (goto-char 4)
+    (should (region-active-p))
+    (hui-kill-region)
+    (should (string= "(456)789" (buffer-string))))
+
+  (with-temp-buffer
+    (transient-mark-mode 0)
+    (insert "123")
+    (goto-char 1)
+
+    ;; No mark set
+    (should-error (hui-kill-region) :type 'error)
+
+    (set-mark (point))
+    (hui-kill-region)
+    (should (looking-at-p "123"))
+
+    (goto-char (point-max))
+    (should-not (region-active-p))
+    (hui-kill-region)
+    (beginning-of-buffer)
+    (should (string= "" (buffer-string)))
+
+    (insert "123(456)789")
+    (goto-char 1)
+    (set-mark (point))
+    (goto-char 4)
+    (deactivate-mark)
+    (should-not (region-active-p))
+    (funcall-interactively 'hui-kill-region)
+    (should (string= "(456)789" (buffer-string)))
+
+    (delete-region (point-min) (point-max))
+    (insert "123(456)789")
+    (goto-char 1)
+    (set-mark (point))
+    (goto-char 4)
+    (should-not (region-active-p))
+    (funcall-interactively 'hui-kill-region)
+    (should (string= "(456)789" (buffer-string)))
+
+    (delete-region (point-min) (point-max))
+    (insert "123(456)789")
+    (goto-char 1)
+    (set-mark (point))
+    (goto-char 4)
+    (deactivate-mark)
+    (should-not (region-active-p))
+    (hui-kill-region)
+    (should (string= "(456)789" (buffer-string)))
+
+    (delete-region (point-min) (point-max))
+    (insert "123(456)789")
+    (goto-char 1)
+    (set-mark (point))
+    (goto-char 4)
+    (should-not (region-active-p))
+    (hui-kill-region)
+    (should (string= "(456)789" (buffer-string)))))
+
 ;; This file can't be byte-compiled without `with-simulated-input' which
 ;; is not part of the actual dependencies, so:
 ;;   Local Variables:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]