[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 6ffb3be674 2/4: Add tests for make-empty-file an
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 6ffb3be674 2/4: Add tests for make-empty-file and dolist-with-progress-reporter |
Date: |
Mon, 16 Jan 2023 05:57:28 -0500 (EST) |
branch: externals/compat
commit 6ffb3be674ee6b66641c252ec80bbb7ecd6ad67b
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add tests for make-empty-file and dolist-with-progress-reporter
---
compat-27.el | 4 ++--
compat-tests.el | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/compat-27.el b/compat-27.el
index 03b228f082..9a74a4d5b8 100644
--- a/compat-27.el
+++ b/compat-27.el
@@ -207,7 +207,7 @@ CONDITION can also be a list of error conditions."
(declare (debug t) (indent 1))
`(condition-case nil (progn ,@body) (,condition nil)))
-(compat-defmacro dolist-with-progress-reporter (spec reporter-or-message &rest
body) ;; <UNTESTED>
+(compat-defmacro dolist-with-progress-reporter (spec reporter-or-message &rest
body) ;; <compat-tests:dolist-with-progress-reporter>
"Loop over a list and report progress in the echo area.
Evaluate BODY with VAR bound to each car from LIST, in turn.
Then evaluate RESULT to get return value, default nil.
@@ -462,7 +462,7 @@ REMOTE is non-nil, search on the remote host indicated by
(when (stringp res) (file-local-name res)))
(executable-find command)))
-(compat-defun make-empty-file (filename &optional parents) ;; <UNTESTED>
+(compat-defun make-empty-file (filename &optional parents) ;;
<compat-tests:make-empty-file>
"Create an empty file FILENAME.
Optional arg PARENTS, if non-nil then creates parent dirs as needed."
(when (and (file-exists-p filename) (null parents))
diff --git a/compat-tests.el b/compat-tests.el
index a6f19388da..a12ba12def 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -80,6 +80,18 @@
(setq list (funcall sym list "first" 1 #'string=))
(should (eq (compat-call plist-get list "first" #'string=) 1))))
+(ert-deftest dolist-with-progress-reporter ()
+ (let (y)
+ (should-equal
+ (dolist-with-progress-reporter (x '(1 2 3) y) "Reporter"
+ (push x y))
+ '(3 2 1)))
+ (let (y)
+ (should-equal
+ (dolist-with-progress-reporter (x '(1 2 3) y) (make-progress-reporter
"Reporter")
+ (push x y))
+ '(3 2 1))))
+
(ert-deftest with-minibuffer-selected-window ()
(let (ran)
(should-not (minibuffer-selected-window))
@@ -1119,6 +1131,14 @@
(should (directory-name-p "dir/subdir/"))
(should-not (directory-name-p "dir/subdir")))
+(ert-deftest make-empty-file ()
+ (let ((name (make-temp-name "compat-tests")))
+ (should-not (file-exists-p name))
+ (make-empty-file name)
+ (should-equal 0 (file-attribute-size (file-attributes name)))
+ (should (file-exists-p name))
+ (delete-file name)))
+
(ert-deftest mounted-file-systems ()
(should-not (string-match-p mounted-file-systems "/etc/"))
(should (string-match-p mounted-file-systems "/mnt/")))