[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole aeb5a31 37/50: Add defal defil tests plus som
From: |
Stefan Monnier |
Subject: |
[elpa] externals/hyperbole aeb5a31 37/50: Add defal defil tests plus some extras (#49) |
Date: |
Wed, 17 Mar 2021 18:44:20 -0400 (EDT) |
branch: externals/hyperbole
commit aeb5a3121c917ef2bf3b7ef79a8f8855e3fe6d41
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: GitHub <noreply@github.com>
Add defal defil tests plus some extras (#49)
* Mock man since it runs asynchronously
* Add tests for defal and defil
* Keep case on replacement text
Co-authored-by: Mats Lidell <matsl@gnu.org>
---
Changes | 10 +++++++++
hbut.el | 2 +-
test/demo-tests.el | 16 ++++++--------
test/hbut-tests.el | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
test/hibtypes-tests.el | 16 +++++---------
5 files changed, 84 insertions(+), 20 deletions(-)
diff --git a/Changes b/Changes
index 801a325..f103344 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,13 @@
+2021-02-28 Mats Lidell <matsl@gnu.org>
+
+* hbut.el (defil): Use FIXEDCASE is non-nil to not alter the case of the
+ replacement text.
+
+* test/hbut-tests.el (hbut-defal, hbut-defal-fails-on-file-missing)
+ (hbut-defil): Test for defal and defil implicit button macros.
+
+* (demo-man-appropos-test, ibtypes::man-apropos-test): Mock call to man.
+
2021-02-21 Bob Weiner <rsw@gnu.org>
* hyperbole.el (hkey-define-key): Removed, had bug that did not use prefix
diff --git a/hbut.el b/hbut.el
index ec8662d..36c5692 100644
--- a/hbut.el
+++ b/hbut.el
@@ -1802,7 +1802,7 @@ commit changes."
(hact ,link-expr button-text)
(let ((referent (when (and button-text (stringp ,link-expr)
(string-match ,text-regexp
button-text))
- (replace-match ,link-expr nil nil
button-text))))
+ (replace-match ,link-expr t nil
button-text))))
(ibtype:activate-link referent))))))
(put (intern (format "ibtypes::%s" ',type))
'function-documentation
diff --git a/test/demo-tests.el b/test/demo-tests.el
index 44f50e8..e258f4e 100644
--- a/test/demo-tests.el
+++ b/test/demo-tests.el
@@ -24,6 +24,7 @@
(require 'hib-social)
(require 'eww)
(require 'compile)
+(require 'el-mock)
(load (expand-file-name "hy-test-helpers"
(file-name-directory (or load-file-name
@@ -347,15 +348,12 @@
;; Man appropos
(ert-deftest demo-man-appropos-test ()
- (unwind-protect
- (with-temp-buffer
- (insert "rm (1) - remove")
- (goto-char 4)
- (action-key)
- (sit-for 0.2)
- (set-buffer "*Man 1 rm*")
- (should (looking-at "RM\(1\)")))
- (kill-buffer "*Man 1 rm*")))
+ (with-temp-buffer
+ (insert "rm (1) - remove")
+ (goto-char 4)
+ (with-mock
+ (mock (man "rm(1)") => t)
+ (action-key))))
;; Explicit buttons
(ert-deftest demo-factorial-test ()
diff --git a/test/hbut-tests.el b/test/hbut-tests.el
new file mode 100644
index 0000000..766f755
--- /dev/null
+++ b/test/hbut-tests.el
@@ -0,0 +1,60 @@
+;;; hbut-tests.el --- hbut unit tests -*- lexical-binding: t; -*-
+
+;; Author: Mats Lidell <matsl@gnu.org>
+;;
+;; Orig-Date: 28-Feb-21 at 22:52:00
+;;
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+;; See the "HY-COPY" file for license information.
+;;
+;; This file is part of GNU Hyperbole.
+
+;;; Commentary:
+
+;; Runs unit tests on some of the examples given in the DEMO file.
+
+;;; Code:
+
+(require 'ert)
+(require 'hbut)
+
+(ert-deftest hbut-defal ()
+ (defal hfile "${hyperb:dir}/\\1")
+ (unwind-protect
+ (with-temp-buffer
+ (insert "<hfile DEMO>")
+ (goto-char 4)
+ (action-key)
+ (should (string= (concat hyperb:dir "DEMO") buffer-file-name))))
+ (progn
+ (kill-buffer "DEMO")
+ (fmakunbound 'ibtypes::hfile)))
+
+(ert-deftest hbut-defal-fails-on-file-missing ()
+ (defal hfile "${hyperb:dir}/\\1")
+ (unwind-protect
+ (with-temp-buffer
+ (insert "<hfile UNKNOWN-FILE>")
+ (goto-char 4)
+ (condition-case err
+ (action-key)
+ (error
+ (progn
+ (should (equal (car err) 'error))
+ (should (string-search "hpath:find" (cadr err)))))))
+ (fmakunbound 'ibtypes::hfile)))
+
+(ert-deftest hbut-defil ()
+ (defil hfile "<<<" ">>>" ".*" "${hyperb:dir}/\\&")
+ (unwind-protect
+ (with-temp-buffer
+ (insert "<<<DEMO>>>")
+ (goto-char 4)
+ (action-key)
+ (should (string= (concat hyperb:dir "DEMO") buffer-file-name)))
+ (progn
+ (kill-buffer "DEMO")
+ (fmakunbound 'ibtypes::hfile))))
+
+(provide 'hbut-tests)
+;;; hbut-tests.el ends here
diff --git a/test/hibtypes-tests.el b/test/hibtypes-tests.el
index 71041ce..b0a4cc5 100644
--- a/test/hibtypes-tests.el
+++ b/test/hibtypes-tests.el
@@ -189,16 +189,12 @@
;; man-apropos
(ert-deftest ibtypes::man-apropos-test ()
- (unwind-protect
- (with-temp-buffer
- (insert "rm (1) - remove")
- (goto-char 4)
- (ibtypes::man-apropos)
- (sit-for 0.2)
- (set-buffer "*Man 1 rm*")
- (should (looking-at "RM\(1\)")))
- (kill-buffer "*Man 1 rm*")))
-
+ (with-temp-buffer
+ (insert "rm (1) - remove")
+ (goto-char 4)
+ (with-mock
+ (mock (man "rm(1)") => t)
+ (ibtypes::man-apropos))))
;; klink
- [elpa] externals/hyperbole d1dcd54 41/50: * Disable magit-auto-revert-mode-enable-in-buffers in hyrolo buffer, (continued)
- [elpa] externals/hyperbole d1dcd54 41/50: * Disable magit-auto-revert-mode-enable-in-buffers in hyrolo buffer, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole c7d62e1 46/50: Make defil handle action type symbols and strings, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 6b2c073 49/50: Correct test cases failing on mac (#55), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 4eef4e9 50/50: Install with-simulated-input if not available (#54), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 25ba634 31/50: Add fast window link button creation via {M-o w} with Ace Window., Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 64579b0 30/50: Fix defil with function improper call to regexp-quote, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole fccc0e5 42/50: Limit Action Button function arg to parameter after function name, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 1219e12 35/50: Merge branch 'master' of hyperbole, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 9ca5b0f 45/50: More tests for ib with labels (#53), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole cd36bea 39/50: Add more defal and defil tests (#51), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole aeb5a31 37/50: Add defal defil tests plus some extras (#49),
Stefan Monnier <=
- [elpa] externals/hyperbole 1c21784 44/50: Add tests for ib with labels (#52), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole faa061e 48/50: Magit Action/Assist Mouse Key on header line toggles diff/all sections visibility, Stefan Monnier, 2021/03/17