branch: externals/hyperbole
commit fa3506a480ba0bca3febd7f41246c6f1253913a1
Author: Mats Lidell <mats.lid...@lidells.se>
Commit: GitHub <nore...@github.com>

    Add test for hui:kill-region and restoring with yank (#760)
    
    Add related test for hui-select-boundaries.
---
 ChangeLog         |  3 ++
 test/hui-tests.el | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 49c8096d08..d2e973f3bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2025-06-24  Mats Lidell  <ma...@gnu.org>
 
+* test/hui-tests.el (hui--kill-region-delimited-text-and-yank-back)
+    (hui--select-boundaries): Add tests.
+
 * test/hywiki-tests.el 
(hywiki-tests--create-wikiword-file-highlights-wikiword):
     Verify creating a file for WikiWord highlights the instances of
     WikiWord that already is present in other files.
diff --git a/test/hui-tests.el b/test/hui-tests.el
index f0bc4da1c9..e60280e48a 100644
--- a/test/hui-tests.el
+++ b/test/hui-tests.el
@@ -1,9 +1,9 @@
-;ui-tests.el --- tests for hui.el Hyperbole UI          -*- lexical-binding: 
t; -*-
+;; hui-tests.el --- tests for hui.el Hyperbole UI          -*- 
lexical-binding: t; -*-
 ;;
 ;; Author:       Mats Lidell <ma...@gnu.org>
 ;;
 ;; Orig-Date:    30-Jan-21 at 12:00:00
-;; Last-Mod:     23-Jun-25 at 00:16:35 by Mats Lidell
+;; Last-Mod:     24-Jun-25 at 23:15:42 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1446,6 +1446,86 @@ line 1
       (should (string= "abcjkl" (buffer-string)))
       (should (string= "{def}{ghi}" (car kill-ring))))))
 
+(ert-deftest hui--select-boundaries ()
+  "Verify `hui-select-boundaries´."
+    (with-temp-buffer
+      (let ((hui-select-region (cons nil nil))
+            (hui-select-previous 'char)
+            (hui-select-old-region (cons nil nil)))
+        (text-mode)
+        (insert "hi\n")
+        (goto-char 1)
+        (should (equal '(1 . 3) (hui-select-boundaries (point))))))
+    (with-temp-buffer
+      (let ((hui-select-region (cons nil nil))
+            (hui-select-previous 'char)
+            (hui-select-old-region (cons nil nil)))
+        (text-mode)
+        (insert "hi")
+        (goto-char 1)
+        (should (equal '(1 . 1) (hui-select-boundaries (point))))))
+    (with-temp-buffer
+      (let ((hui-select-region (cons nil nil))
+            (hui-select-previous 'char)
+            (hui-select-old-region (cons nil nil)))
+        (text-mode)
+        (insert "<hi>\n")
+        (goto-char 2)
+        (should (equal '(2 . 4) (hui-select-boundaries (point))))))
+    (with-temp-buffer
+      (let ((hui-select-region (cons nil nil))
+            (hui-select-previous 'char)
+            (hui-select-old-region (cons nil nil)))
+        (text-mode)
+        (insert "<hi>\n")
+        (goto-char 1)
+        (should (equal '(1 . 5) (hui-select-boundaries (point))))))
+    (with-temp-buffer
+      (let ((hui-select-region (cons nil nil))
+            (hui-select-previous 'char)
+            (hui-select-old-region (cons nil nil)))
+        (text-mode)
+        (insert "<hi>")
+        (goto-char 1)
+        (should (equal '(1 . 1) (hui-select-boundaries (point)))))))
+
+(ert-deftest hui--kill-region-delimited-text-and-yank-back ()
+  "Verify multiple `hui:kill-region' followed by a `yank' restores contents."
+  :expected-result :failed
+  (with-temp-buffer
+    (let ((transient-mark-mode t)
+          (mark-even-if-inactive t)
+          last-command)
+      (insert "<hi>")
+      (goto-char 2)
+      (setq last-command #'ignore)
+      (call-interactively #'hui:kill-region)
+      (should (string= (buffer-string) "<>"))
+      (yank)
+      (should (string= (buffer-string) "<hi>"))))
+  (with-temp-buffer
+    (let ((transient-mark-mode t)
+          (mark-even-if-inactive t)
+          last-command)
+      (insert "<hi>\n")
+      (goto-char 1)
+      (setq last-command #'ignore)
+      (call-interactively #'hui:kill-region)
+      (should (string= (buffer-string) "\n"))
+      (yank)
+      (should (string= (buffer-string) "<hi>\n"))))
+  (with-temp-buffer
+    (let ((transient-mark-mode t)
+          (mark-even-if-inactive t)
+          last-command)
+      (insert "<hi>")
+      (goto-char 1)
+      (setq last-command #'ignore)
+      (call-interactively #'hui:kill-region)
+      (should (string= (buffer-string) ""))
+      (yank)
+      (should (string= (buffer-string) "<hi>")))))
+
 ;; This file can't be byte-compiled without the `el-mock' which
 ;; is not part of the actual dependencies, so:
 ;;   Local Variables:

Reply via email to