branch: externals/hyperbole commit 97111e4bd022451356f570612759629f60729c44 Merge: e1483d9cff 6c5002e670 Author: bw <r...@gnu.org> Commit: bw <r...@gnu.org>
Merge branch 'master' into rsw --- ChangeLog | 26 +++++++++++++ hmouse-tag.el | 3 +- test/hy-test-helpers.el | 4 +- test/hyrolo-tests.el | 9 +++-- test/hywconfig-tests.el | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b782e7b19..f1ebf9083d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -32,6 +32,11 @@ * hyrolo.el (hyrolo-move-backward): Change 'outline-previous-heading' call to 'hyrolo-outline-previous-heading'. +2023-12-09 Mats Lidell <ma...@gnu.org> + +* test/hy-test-helpers.el (hy-test-helpers:consume-input-events): Remove + not needed recursion-depth check. + 2023-12-09 Bob Weiner <r...@gnu.org> * hyrolo.el (hyrolo-funcall-match, hyrolo-map-matches): Add these functions to @@ -67,6 +72,18 @@ They are no longer used. Move header matching in `outline-regexp' and `hyrolo-entry-regexp' to 'hyrolo--cache-matched-buffer'. +2023-12-07 Mats Lidell <ma...@gnu.org> + +* test/hywconfig-tests.el (hywconfig-tests--remove-ring) + (hywconfig-tests--remove-names): Support functions for clearing the + window config per frame. + (hywconfig--inital-ring-is-empty, hywconfig--not-empty-if-ring-save) + (hywconfig--number-of-configs-are-store-up-to-a-max) + (hywconfig--empty-after-pop-ring-with-one-config) + (hywconfig--max-minus-one-after-pop-ring-with-max-config) + (hywconfig--get-not-existing-config-fails, hywconfig--add-by-name) + (hywconfig--delete-by-name): Tests. + 2023-12-04 Bob Weiner <r...@gnu.org> * Makefile (HY-TALK/HYPER*.org): Add Hyperbole talk slides from EmacsConf @@ -112,6 +129,15 @@ * kotl/kotl-mode.el (kotl-mode:example): Fix to prompt to save in home directory, not the current directory. +2023-12-01 Mats Lidell <ma...@gnu.org> + +* hmouse-tag.el (ibtype:def-symbol): Declare function to silence warning. + +* test/hyrolo-tests.el (hyrolo-sort-test): Set default date format so the + format used is well defined. + (hyrolo-fgrep-and-goto-next-visible-md-heading): Use level one heading + so that heading hierarchy is respected. + 2023-12-01 Bob Weiner <r...@gnu.org> * hyrolo.el (hyrolo-add): Fix that narrow-to-region was narrowing to a diff --git a/hmouse-tag.el b/hmouse-tag.el index 1c68a65ae6..dbd039e5aa 100644 --- a/hmouse-tag.el +++ b/hmouse-tag.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 24-Aug-91 -;; Last-Mod: 22-Nov-23 at 00:15:24 by Bob Weiner +;; Last-Mod: 1-Dec-23 at 23:32:23 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -80,6 +80,7 @@ (declare-function hsys-org-get-value "hsys-org") (declare-function org-in-src-block-p "org") +(declare-function ibtype:def-symbol "hbut") ;; Forward declare needed? Because of optional defined above? Can we ;; skip checking if xref is available since it has been at least since diff --git a/test/hy-test-helpers.el b/test/hy-test-helpers.el index ddb7e95dd3..c20d35a73b 100644 --- a/test/hy-test-helpers.el +++ b/test/hy-test-helpers.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 30-Jan-21 at 12:00:00 -;; Last-Mod: 7-Jul-23 at 17:09:59 by Mats Lidell +;; Last-Mod: 31-Oct-23 at 22:48:26 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -24,7 +24,7 @@ (defun hy-test-helpers:consume-input-events () "Use recusive-edit to consume the events kbd-key generates." - (run-with-timer 0.1 nil (lambda () (if (< 0 (recursion-depth)) (exit-recursive-edit)))) + (run-with-timer 0.1 nil (lambda () (exit-recursive-edit))) (recursive-edit)) (defun hy-test-helpers:should-last-message (msg) diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 60946266a8..cf125e6e28 100644 --- a/test/hyrolo-tests.el +++ b/test/hyrolo-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 19-Jun-21 at 22:42:00 -;; Last-Mod: 29-Nov-23 at 23:22:15 by Mats Lidell +;; Last-Mod: 1-Dec-23 at 23:20:39 by Mats Lidell ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -207,7 +207,8 @@ and {b} the previous same level cell." :expected-result :failed (let ((hyrolo-file (make-temp-file "hypb" nil ".otl"))) (unwind-protect - (let ((hyrolo-file-list (list hyrolo-file))) + (let ((hyrolo-file-list (list hyrolo-file)) + (hyrolo-date-format "%m/%d/%Y")) (hyrolo-find-file (car (hyrolo-get-file-list))) (insert "===\nHdr\n===\n") (goto-char (point-min)) @@ -365,7 +366,7 @@ and {b} the previous same level cell." "Verify move to next heading, then action-key to go to record for markdown mode." :expected-result :failed (let* ((temporary-file-directory (make-temp-file "hypb" t)) - (md-file (make-temp-file "hypb" nil ".md" "## heading\nstring\nmore\n")) + (md-file (make-temp-file "hypb" nil ".md" "# heading\nstring\nmore\n")) (hyrolo-file-list (list temporary-file-directory))) (unwind-protect (progn @@ -378,7 +379,7 @@ and {b} the previous same level cell." (with-simulated-input "y RET" ; Do you want to revisit the file normally now? (action-key) (should (equal (current-buffer) (find-buffer-visiting md-file))) - (should (looking-at-p "## heading")))) + (should (looking-at-p "# heading")))) (hy-delete-file-and-buffer md-file) (kill-buffer "*HyRolo*") (delete-directory temporary-file-directory)))) diff --git a/test/hywconfig-tests.el b/test/hywconfig-tests.el new file mode 100644 index 0000000000..6c44ae8ded --- /dev/null +++ b/test/hywconfig-tests.el @@ -0,0 +1,100 @@ +;;; hywconfig-tests.el --- unit tests for hywconfig -*- lexical-binding: t; -*- + +;; Author: Mats Lidell <ma...@gnu.org> +;; +;; Orig-Date: 30-Jan-21 at 12:00:00 +;; Last-Mod: 7-Dec-23 at 23:17:36 by Mats Lidell +;; +;; SPDX-License-Identifier: GPL-3.0-or-later +;; +;; Copyright (C) 2023 Free Software Foundation, Inc. +;; See the "HY-COPY" file for license information. +;; +;; This file is part of GNU Hyperbole. + +;;; Commentary: + +;; Unit tests for "../hywconfig.el" + +;;; Code: + +(require 'hywconfig) +(require 'ert) + +(defun hywconfig-tests--remove-ring () + "Remove ring from frame parameters." + (set-frame-parameter nil 'hywconfig-ring nil)) + +(defun hywconfig-tests--remove-names () + "Remove names from frame parameters." + (set-frame-parameter nil 'hywconfig-names nil)) + +(ert-deftest hywconfig--inital-ring-is-empty () + "Verify an initial ring is empty." + (hywconfig-tests--remove-ring) + (should (hywconfig-ring-empty-p))) + +(ert-deftest hywconfig--not-empty-if-ring-save () + "Verify ring is not empty after saving a configuration." + (hywconfig-tests--remove-ring) + (hywconfig-ring-save) + (should-not (hywconfig-ring-empty-p))) + +(ert-deftest hywconfig--number-of-configs-are-store-up-to-a-max () + "Verify there is a max of number of configuration that can be saved." + (let ((hywconfig-ring-max 2)) + (hywconfig-tests--remove-ring) + (hywconfig-ring-save) + (hywconfig-ring-save) + (should (= (ring-length (hywconfig-get-ring)) hywconfig-ring-max)) + (hywconfig-ring-save) + (should (= (ring-length (hywconfig-get-ring)) hywconfig-ring-max)))) + +(ert-deftest hywconfig--empty-after-pop-ring-with-one-config () + "Verify ring is not empty after saving a configuration." + (hywconfig-tests--remove-ring) + (hywconfig-ring-save) + (hywconfig-delete-pop) + (should (hywconfig-ring-empty-p))) + +(ert-deftest hywconfig--max-minus-one-after-pop-ring-with-max-config () + "Verify ring is not empty after saving a configuration." + (let ((hywconfig-ring-max 2)) + (hywconfig-tests--remove-ring) + (hywconfig-ring-save) + (hywconfig-ring-save) + (hywconfig-delete-pop) + (should (= (ring-length (hywconfig-get-ring)) (1- hywconfig-ring-max))))) + +(ert-deftest hywconfig--get-not-existing-config-errors () + "Verify retrieving a config that has not been saved gives an error message." + (hywconfig-tests--remove-names) + (let ((err (should-error (hywconfig-restore-by-name "config") :type 'error))) + (should (string-match-p "No window configuration for this frame named" (cadr err))))) + +(ert-deftest hywconfig--add-by-name () + "Verify config is added by name." + :expected-result :failed + ;; See backtrace for the error - (wrong-type-argument listp #<window-configuration>) + ;; set:member("config" (#<window-configuration>)) + ;; set:get("config" (#<window-configuration>)) + ;; (let ((wconfig (set:get name (hywconfig-get-names)))) (if wconfig (progn (hywconfig-set-window-configuration wconfig) (if (called-interactively-p 'interactive) (progn (message "Window configuration `%s' is now active." name)))) (error "(hywconfig-restore-by-name): No window configuration for this frame named `%s'" name))) + ;; (cond ((null name) (message "There is no named window configuration to restore.")) ((not (stringp name)) (error "(hywconfig-restore-by-name): `name' argument is not a string: %s" name)) (t (let ((wconfig (set:get name (hywconfig-get-names)))) (if wconfig (progn (hywconfig-set-window-configuration wconfig) (if (called-interactively-p 'interactive) (progn (message "Window configuration `%s' is now active." name)))) (error "(hywconfig-restore-by-name): No window configuration for this [...] + ;; hywconfig-restore-by-name("config") + ;; [...] + (hywconfig-tests--remove-names) + (hywconfig-add-by-name "config") + (should (hywconfig-restore-by-name "config"))) + +(ert-deftest hywconfig--delete-by-name () + "Verify config can be deleted by name." + :expected-result :failed + ;; Same error as above + (hywconfig-tests--remove-names) + (hywconfig-add-by-name "config") + (hywconfig-delete-by-name "config") + (let ((err (should-error (hywconfig-restore-by-name "config") :type 'error))) + (should (string--p "No window configuration for this frame named" (cadr err))))) + +(provide 'hywconfig-tests) +;;; hywconfig-tests.el ends here