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

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

[elpa] externals/hyperbole 2e295f2491: Test anchor with white space and


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 2e295f2491: Test anchor with white space and trailing text (#358)
Date: Thu, 13 Jul 2023 06:57:59 -0400 (EDT)

branch: externals/hyperbole
commit 2e295f24919d6f53f76f30d978069dd43d2530ba
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: GitHub <noreply@github.com>

    Test anchor with white space and trailing text (#358)
---
 ChangeLog                |   6 +++
 test/hmouse-drv-tests.el | 107 ++++++++++++++++++++++++++++++-----------------
 test/hy-test-helpers.el  |   4 +-
 3 files changed, 77 insertions(+), 40 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e18da39943..576ec5365f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-07-13  Mats Lidell  <matsl@gnu.org>
+
+* test/hmouse-drv-tests.el (hbut-pathname-anchor-must-match-all)
+    (hbut-pathname-anchor-trailing-text): Add tests for pathname with
+    anchor.
+
 2023-07-11  Mats Lidell  <matsl@gnu.org>
 
 * Makefile (version, $(pkg_parent)/hyperbole-$(HYPB_VERSION).tar): Do not
diff --git a/test/hmouse-drv-tests.el b/test/hmouse-drv-tests.el
index 1804acde3f..99062bce2c 100644
--- a/test/hmouse-drv-tests.el
+++ b/test/hmouse-drv-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <matsl@gnu.org>
 ;;
 ;; Orig-Date:    28-Feb-21 at 22:52:00
-;; Last-Mod:     19-Feb-23 at 15:49:31 by Mats Lidell
+;; Last-Mod:     13-Jul-23 at 00:45:55 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -76,7 +76,7 @@
     (ibtype:delete 'ibtypes::defal-key)))
 
 (defun hbut-verify-defal (x)
-  "Verify function i called with X set to the string `test'."
+  "Verify function is called with X set to the string `test'."
   (should (string= x "test")))
 
 (ert-deftest hbut-defal-function ()
@@ -86,9 +86,8 @@
       (with-temp-buffer
         (insert "<defal-func test>")
         (goto-char 4)
-        (action-key)))
-    (progn
-      (ibtype:delete 'ibtypes::defal-func)))
+        (action-key))
+    (ibtype:delete 'ibtypes::defal-func)))
   
 (ert-deftest hbut-defal-fails-on-file-missing ()
   (defal defal-path-missing "${hyperb:dir}/\\1")
@@ -173,7 +172,7 @@
       (action-key))))
 
 (ert-deftest hbut-ib-create-label ()
-  "Create a label for an implicit button"
+  "Create a label for an implicit button."
   (with-temp-buffer
     (insert "\"/tmp\"\n")
     (goto-char 3)
@@ -253,15 +252,13 @@
     (kill-buffer "DEMO")))
 
 (ert-deftest hbut-pathname-env-variable-test ()
-  (unwind-protect
-      (with-temp-buffer
-        (insert "\"${HOME}\"")
-        (goto-char 2)
-        (action-key)
-        (should (equal major-mode 'dired-mode))
-       (should (= 0 (string-match (file-truename (getenv "HOME"))
-                                  (file-truename default-directory)))))
-    nil))
+  (with-temp-buffer
+    (insert "\"${HOME}\"")
+    (goto-char 2)
+    (action-key)
+    (should (equal major-mode 'dired-mode))
+    (should (= 0 (string-match (file-truename (getenv "HOME"))
+                              (file-truename default-directory))))))
 
 (ert-deftest hbut-pathname-emacs-lisp-file-test ()
   (unwind-protect
@@ -271,43 +268,78 @@
         (action-key)
         (should (equal major-mode 'emacs-lisp-mode))
         (should (buffer-file-name))
-        (should (string= "hyperbole.el" (buffer-name)))))
-  (kill-buffer "hyperbole.el"))
+        (should (string= "hyperbole.el" (buffer-name))))
+    (kill-buffer "hyperbole.el")))
 
 (ert-deftest hbut-pathname-anchor-test ()
   "Pathname with anchor."
+  (let ((file (make-temp-file "hypb" nil nil
+                              "Text\n* Anchor\n")))
+    (unwind-protect
+        (with-temp-buffer
+          (insert (concat "\"" file "#Anchor\""))
+          (goto-char 2)
+          (action-key)
+          (should (string= file (buffer-file-name)))
+          (should (looking-at "\* Anchor")))
+      (hy-delete-file-and-buffer file))))
+
+(ert-deftest hbut-pathname-anchor-trailing-text ()
+  "Pathname with anchor and trailing parenthesised text."
+  (let ((file (make-temp-file "hypb" nil nil
+                              "Text\n* Anchor Plus (Parenthesised text 
follows)\n")))
   (unwind-protect
       (with-temp-buffer
-        (insert "\"${hyperb:dir}/DEMO#Smart Keys\"")
+        (insert (concat "\"" file "#Anchor Plus\""))
         (goto-char 2)
         (action-key)
-        (should (string= "DEMO" (buffer-name)))
-        (should (looking-at "\* Smart Keys")))
-    (kill-buffer "DEMO")))
+        (should (string= file (buffer-file-name)))
+        (should (looking-at "\* Anchor Plus \(Parenthesised text follows\)")))
+    (hy-delete-file-and-buffer file))))
+
+(ert-deftest hbut-pathname-anchor-must-match-all ()
+  "Verify that the whole anchor must match."
+  (let ((file (make-temp-file "hypb" nil nil
+                              "Text\n* Anchor Plus non parenthesised text\n")))
+  (unwind-protect
+      (with-temp-buffer
+        (insert (concat "\"" file "#Anchor Plus\""))
+        (goto-char 2)
+        (let ((err (should-error (action-key) :type 'error)))
+          (should (string-match-p
+                   (concat "\(hpath:to-markup-anchor\): "
+                           (buffer-name)
+                           " - Section .Anchor Plus. not found in the visible 
buffer portion")
+                   (cadr err)))))
+    (hy-delete-file-and-buffer file))))
 
 (ert-deftest hbut-pathname-anchor-line-test ()
   "Pathname with anchor and line specification."
+  (let ((file (make-temp-file "hypb" nil nil
+                              "Text\n* Anchor\nNext Line\n")))
   (unwind-protect
       (with-temp-buffer
-        (insert "\"${hyperb:dir}/DEMO#Smart Keys:2\"")
+        (insert (concat "\"" file "#Anchor:1\""))
         (goto-char 2)
         (action-key)
-        (should (string= "DEMO" (buffer-name)))
-        (forward-line -2)
-        (should (looking-at "\* Smart Keys")))
-    (kill-buffer "DEMO")))
+        (should (string= file (buffer-file-name)))
+        (should (looking-at "Next Line")))
+    (hy-delete-file-and-buffer file))))
 
 (ert-deftest hbut-pathname-line-column-test ()
   "Pathname with line and position specification."
-  (unwind-protect
-      (with-temp-buffer
-        (insert "\"${hyperb:dir}/DEMO:3:45\"")
-        (goto-char 2)
-        (action-key)
-        (should (string= "DEMO" (buffer-name)))
-        (should (= (line-number-at-pos) 3))
-        (should (= (current-column) 45)))
-    (kill-buffer "DEMO")))
+  (let ((file (make-temp-file "hypb" nil nil
+                              "Text\n* Anchor\nNext Line\n")))
+    (unwind-protect
+        (with-temp-buffer
+          (insert (concat "\"" file "#Anchor:1:5\""))
+          (goto-char 2)
+          (action-key)
+          (should (string= file (buffer-file-name)))
+          (should (= (line-number-at-pos) 3))
+          (should (= (current-column) 5))
+          (should (looking-at "Line")))
+      (hy-delete-file-and-buffer file))))
 
 (ert-deftest hbut-pathname-load-path-line-column-test ()
   "Pathname with `load-path', line and position specification."
@@ -426,9 +458,8 @@
         (let ((hpath:display-where 'this-window))
           (action-key)
           (should (string= "HY-ABOUT" (buffer-name)))))
-    (progn
-      (kill-buffer "MANIFEST")
-      (kill-buffer "HY-ABOUT"))))
+    (kill-buffer "MANIFEST")
+    (kill-buffer "HY-ABOUT")))
 
 ;; rfc
 (ert-deftest hbut-rfc-test ()
diff --git a/test/hy-test-helpers.el b/test/hy-test-helpers.el
index c5bfb2522c..892d4a4869 100644
--- a/test/hy-test-helpers.el
+++ b/test/hy-test-helpers.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <matsl@gnu.org>
 ;;
 ;; Orig-Date:    30-Jan-21 at 12:00:00
-;; Last-Mod:     28-May-23 at 22:52:40 by Mats Lidell
+;; Last-Mod:      7-Jul-23 at 17:09:59 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -70,7 +70,7 @@ Checks ACTYPE, ARGS, LOC and LBL-KEY."
     (should (equal (hattr:get hbut-at-p 'name) name))))
 
 (defun hy-delete-file-and-buffer (file)
-  "Delete file and buffer vistinng file."
+  "Delete FILE and buffer visiting file."
   (let ((buf (find-buffer-visiting file)))
     (when buf
       (with-current-buffer buf



reply via email to

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