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

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

[elpa] externals/hyperbole 9f2eff61f2 10/14: Merge pull request #600 fro


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 9f2eff61f2 10/14: Merge pull request #600 from rswgnu/add-more-hywiki-tests
Date: Mon, 11 Nov 2024 03:58:24 -0500 (EST)

branch: externals/hyperbole
commit 9f2eff61f2a10319e2ee93b2090a437c1a2f3a1e
Merge: 3555e549f8 aecb4ec856
Author: Robert Weiner <rsw@gnu.org>
Commit: GitHub <noreply@github.com>

    Merge pull request #600 from rswgnu/add-more-hywiki-tests
    
    add more hywiki tests
---
 ChangeLog            |  22 +++++++++
 test/hywiki-tests.el | 136 ++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 145 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2899e1dd74..9353a6c109 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-11-10  Mats Lidell  <matsl@gnu.org>
+
+* test/hywiki-tests.el (hywiki-tests--add-hywiki-hooks)
+    (hywiki-tests--remove-hywiki-hooks, with-hywiki-buttonize-hooks)
+    (with-hywiki-buttonize-and-insert-hooks): Add functions and macros for
+    mimicking redisplay hook behavior and use these in the highlighting tests.
+    (hywiki-tests--face-property-for-wikiword-with-wikipage)
+    (hywiki-tests--no-face-property-for-no-wikipage)
+    (hywiki-tests--verify-face-property-when-editing-wikiword)
+    (hywiki-tests--verify-face-property-when-editing-wikiword-first-char):
+    Tests using the hook mimicking functions.
+
+2024-11-02  Mats Lidell  <matsl@gnu.org>
+
+* test/hywiki-tests.el (hywiki-tests--word-is-p)
+    (hywiki-tests--directory-edit)
+    (hywiki-tests--verify-face-property-when-editing-wikiword)
+    (hywiki-tests--verify-face-property-when-editing-wikiword-first-char): Add 
hywiki
+    tests.
+
+* test/hywiki-tests.el (hywiki-tests--word-is-p): Add hywiki test.
+
 2024-10-28  Bob Weiner  <rsw@gnu.org>
 
 * hibtypes.el (hywiki-existing-word): Call action with the singular version
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index 51f7f3af2d..1248ce6ad3 100644
--- a/test/hywiki-tests.el
+++ b/test/hywiki-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell
 ;;
 ;; Orig-Date:    18-May-24 at 23:59:48
-;; Last-Mod:     18-Oct-24 at 22:44:05 by Mats Lidell
+;; Last-Mod:     10-Nov-24 at 23:05:28 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -105,6 +105,13 @@
       (hywiki-mode -1)
       (hy-delete-dir-and-buffer hywiki-directory))))
 
+(ert-deftest hywiki-tests--word-is-p ()
+  "Verify `hywiki-word-is-p' identifies WikiWords."
+  (should (hywiki-word-is-p "WikiWord"))
+  (should (hywiki-word-is-p "WikiWord#section"))
+  (should-not (hywiki-word-is-p "hy:WikiWord"))
+  (should-not (hywiki-word-is-p "wikiWord")))
+
 (ert-deftest hywiki-tests--maybe-at-wikiword-beginning ()
   "Verify `hywiki-maybe-at-wikiword-beginning' identifies if maybe at 
beginning of WikiWord."
   (with-temp-buffer
@@ -252,6 +259,44 @@ Both mod-time and checksum must be changed for a test to 
return true."
 ;; Following three test cases for verifying proper face is some what
 ;; experimental. They need to be run in interactive mode.
 
+(defun hywiki-tests--add-hywiki-hooks ()
+  "Enable all hywiki hook functions."
+  (add-hook 'pre-command-hook      'hywiki-debuttonize-non-character-commands 
95)
+  (add-hook 'post-command-hook     'hywiki-buttonize-non-character-commands 95)
+  (add-hook 'post-self-insert-hook 'hywiki-buttonize-character-commands)
+  (add-hook 'window-buffer-change-functions
+           'hywiki-maybe-highlight-page-names-in-frame)
+  (add-to-list 'yank-handled-properties
+              '(hywiki-word-face . hywiki-highlight-on-yank)))
+
+(defun hywiki-tests--remove-hywiki-hooks ()
+  "Disable all hywiki hook functions."
+  (remove-hook 'pre-command-hook      
'hywiki-debuttonize-non-character-commands)
+  (remove-hook 'post-command-hook     'hywiki-buttonize-non-character-commands)
+  (remove-hook 'post-self-insert-hook 'hywiki-buttonize-character-commands)
+  (remove-hook 'window-buffer-change-functions
+              'hywiki-maybe-highlight-page-names-in-frame)
+  (setq yank-handled-properties
+       (delete '(hywiki-word-face . hywiki-highlight-on-yank)
+               yank-handled-properties)))
+
+(defmacro with-hywiki-buttonize-hooks (&rest body)
+  "Call BODY wrapped in hywiki hooks to simulate Emacs redisplay."
+  (declare (indent 0) (debug t))
+  `(progn
+     (funcall 'hywiki-debuttonize-non-character-commands)
+     (progn ,@body)
+     (funcall 'hywiki-buttonize-non-character-commands)))
+
+(defmacro with-hywiki-buttonize-and-insert-hooks (&rest body)
+  "Call BODY wrapped in hywiki hooks to simulate Emacs redisplay."
+  (declare (indent 0) (debug t))
+  `(progn
+     (funcall 'hywiki-debuttonize-non-character-commands)
+     (progn ,@body)
+     (funcall 'hywiki-buttonize-character-commands)
+     (funcall 'hywiki-buttonize-non-character-commands)))
+
 (ert-deftest hywiki-tests--face-property-for-wikiword-with-wikipage ()
   "Verify WikiWord for a wiki page gets face property hywiki-word-face."
   (skip-unless (not noninteractive))
@@ -259,12 +304,16 @@ Both mod-time and checksum must be changed for a test to 
return true."
          (hywiki-directory (make-temp-file "hywiki" t))
          (wikipage (hywiki-add-page "WikiWord")))
     (unwind-protect
-        (with-temp-buffer
-          (hywiki-mode 1)
-          (insert "WikiWord")
-         (newline nil t)
-          (goto-char 4)
-          (should (hproperty:but-get (point) 'face hywiki-word-face)))
+        (progn
+          (hywiki-tests--remove-hywiki-hooks)
+          (with-temp-buffer
+            (hywiki-mode 1)
+            (with-hywiki-buttonize-and-insert-hooks
+              (insert "WikiWord")
+             (newline nil t))
+            (goto-char 4)
+            (should (hproperty:but-get (point) 'face hywiki-word-face))))
+      (hywiki-tests--add-hywiki-hooks)
       (hywiki-mode 0)
       (hy-delete-file-and-buffer wikipage)
       (hy-delete-dir-and-buffer hywiki-directory))))
@@ -275,12 +324,73 @@ Both mod-time and checksum must be changed for a test to 
return true."
   (let* ((hsys-org-enable-smart-keys t)
          (hywiki-directory (make-temp-file "hywiki" t)))
     (unwind-protect
-        (with-temp-buffer
-          (hywiki-mode 0)
-          (insert "WikiWord")
-         (newline nil t)
-          (goto-char 4)
-          (should-not (hproperty:but-get (point) 'face hywiki-word-face)))
+        (progn
+          (hywiki-tests--remove-hywiki-hooks)
+          (with-temp-buffer
+            (hywiki-mode 0)
+            (with-hywiki-buttonize-and-insert-hooks
+              (insert "WikiWord")
+             (newline nil t))
+            (goto-char 4)
+            (should-not (hproperty:but-get (point) 'face hywiki-word-face))))
+      (hywiki-tests--add-hywiki-hooks)
+      (hy-delete-dir-and-buffer hywiki-directory))))
+
+(ert-deftest hywiki-tests--verify-face-property-when-editing-wikiword ()
+  "Verify face property changes when WikiWord is edited."
+  (skip-unless (not noninteractive))
+  (let* ((hywiki-directory (make-temp-file "hywiki" t))
+         (wikipage (hywiki-add-page "WikiWord")))
+    (unwind-protect
+        (progn
+          (hywiki-tests--remove-hywiki-hooks)
+          (with-temp-buffer
+            (hywiki-mode 1)
+            (with-hywiki-buttonize-and-insert-hooks (insert "Wikiord "))
+            (goto-char 5)
+            (should (looking-at-p "ord"))
+            (should-not (hproperty:but-get (point) 'face hywiki-word-face))
+
+            (with-hywiki-buttonize-and-insert-hooks (insert "W"))
+            (goto-char 5)
+            (should (looking-at-p "Word"))
+            (should (hproperty:but-get (point) 'face hywiki-word-face))
+
+            (with-hywiki-buttonize-and-insert-hooks (delete-char 1))
+            (should (looking-at-p "ord"))
+            (should-not (hproperty:but-get (point) 'face hywiki-word-face))))
+      (hywiki-tests--add-hywiki-hooks)
+      (hywiki-mode 0)
+      (hy-delete-files-and-buffers (list wikipage))
+      (hy-delete-dir-and-buffer hywiki-directory))))
+
+(ert-deftest 
hywiki-tests--verify-face-property-when-editing-wikiword-first-char ()
+  "Verify face property changes when WikiWord is edited in the first char 
position."
+  :expected-result :failed
+  (let* ((hywiki-directory (make-temp-file "hywiki" t))
+         (wikipage (hywiki-add-page "WikiWord")))
+    (skip-unless (not noninteractive))
+    (unwind-protect
+        (progn
+          (hywiki-tests--remove-hywiki-hooks)
+          (with-temp-buffer
+            (hywiki-mode 1)
+            (with-hywiki-buttonize-and-insert-hooks (insert "WikiWord "))
+            (goto-char 1)
+            (should (looking-at-p "Wiki"))
+            (should (hproperty:but-get (point) 'face hywiki-word-face))
+
+            (with-hywiki-buttonize-and-insert-hooks (delete-char 1))
+            (should (looking-at-p "iki"))
+            (should-not (hproperty:but-get (point) 'face hywiki-word-face))
+
+            (with-hywiki-buttonize-and-insert-hooks (insert "W"))
+            (goto-char 1)
+            (should (looking-at-p "Wiki"))
+            (should (hproperty:but-get (point) 'face hywiki-word-face))))
+      (hywiki-tests--add-hywiki-hooks)
+      (hywiki-mode 0)
+      (hy-delete-files-and-buffers (list wikipage))
       (hy-delete-dir-and-buffer hywiki-directory))))
 
 (ert-deftest hywiki-tests--convert-words-to-org-link ()



reply via email to

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