aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStefan Kangas2025-02-24 23:02:20 +0100
committerStefan Kangas2025-02-25 01:23:33 +0100
commit1a22bc0fd672e2c71955faf81ff2cfd1c0c76be9 (patch)
treee9eec52f107c3e70e424dae8b27ba331a4bcab22 /test
parent7bb53815d2bcc7af8bc613e67e2aeb4ec01db901 (diff)
downloademacs-1a22bc0fd672e2c71955faf81ff2cfd1c0c76be9.tar.gz
emacs-1a22bc0fd672e2c71955faf81ff2cfd1c0c76be9.zip
Use cl-with-gensyms in a few more cases
* doc/misc/cl.texi (Macro Bindings): * lisp/emacs-lisp/comp.el (comp--with-sp): * lisp/emacs-lisp/subr-x.el (with-buffer-unmodified-if-unchanged): * lisp/eshell/em-extpipe.el (eshell-extpipe--or-with-catch): * lisp/international/mule-cmds.el (with-locale-environment): * lisp/kmacro.el (kmacro-menu--marks-exist-p): * test/lisp/emacs-lisp/cl-extra-tests.el (cl-lib-test-remprop): * test/lisp/emacs-lisp/edebug-tests.el (edebug-tests-deduplicate): * test/lisp/emacs-lisp/ert-tests.el (ert-test-special-operator-p): * test/lisp/kmacro-tests.el (kmacro-tests-should-insert) (kmacro-tests-should-match-message): * test/lisp/replace-tests.el (replace-tests-with-undo): Use cl-with-gensyms instead of bare gensym call.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/emacs-lisp/cl-extra-tests.el2
-rw-r--r--test/lisp/emacs-lisp/edebug-tests.el3
-rw-r--r--test/lisp/emacs-lisp/ert-tests.el2
-rw-r--r--test/lisp/kmacro-tests.el6
-rw-r--r--test/lisp/replace-tests.el3
5 files changed, 7 insertions, 9 deletions
diff --git a/test/lisp/emacs-lisp/cl-extra-tests.el b/test/lisp/emacs-lisp/cl-extra-tests.el
index 41753194c1b..20d1e532a6f 100644
--- a/test/lisp/emacs-lisp/cl-extra-tests.el
+++ b/test/lisp/emacs-lisp/cl-extra-tests.el
@@ -23,7 +23,7 @@
23(require 'ert) 23(require 'ert)
24 24
25(ert-deftest cl-lib-test-remprop () 25(ert-deftest cl-lib-test-remprop ()
26 (let ((x (cl-gensym))) 26 (cl-with-gensyms (x)
27 (should (equal (symbol-plist x) '())) 27 (should (equal (symbol-plist x) '()))
28 ;; Remove nonexistent property on empty plist. 28 ;; Remove nonexistent property on empty plist.
29 (cl-remprop x 'b) 29 (cl-remprop x 'b)
diff --git a/test/lisp/emacs-lisp/edebug-tests.el b/test/lisp/emacs-lisp/edebug-tests.el
index 02eadd34c8d..7daacea7925 100644
--- a/test/lisp/emacs-lisp/edebug-tests.el
+++ b/test/lisp/emacs-lisp/edebug-tests.el
@@ -321,8 +321,7 @@ NAME should be a string and NAMES-AND-NUMBERS an alist which can
321be used by this macro to retain state. If NAME for example is 321be used by this macro to retain state. If NAME for example is
322\"symbol\" then the first and subsequent uses of this macro will 322\"symbol\" then the first and subsequent uses of this macro will
323evaluate to \"symbol\", \"symbol-1\", \"symbol-2\", etc." 323evaluate to \"symbol\", \"symbol-1\", \"symbol-2\", etc."
324 (let ((g-name (gensym)) 324 (cl-with-gensyms (g-name g-duplicate)
325 (g-duplicate (gensym)))
326 `(let* ((,g-name ,name) 325 `(let* ((,g-name ,name)
327 (,g-duplicate (assoc ,g-name ,names-and-numbers))) 326 (,g-duplicate (assoc ,g-name ,names-and-numbers)))
328 (if (null ,g-duplicate) 327 (if (null ,g-duplicate)
diff --git a/test/lisp/emacs-lisp/ert-tests.el b/test/lisp/emacs-lisp/ert-tests.el
index d4370366b39..aec2c92ba81 100644
--- a/test/lisp/emacs-lisp/ert-tests.el
+++ b/test/lisp/emacs-lisp/ert-tests.el
@@ -617,7 +617,7 @@ This macro is used to test if macroexpansion in `should' works."
617 (should (ert--special-operator-p 'if)) 617 (should (ert--special-operator-p 'if))
618 (should-not (ert--special-operator-p 'car)) 618 (should-not (ert--special-operator-p 'car))
619 (should-not (ert--special-operator-p 'ert--special-operator-p)) 619 (should-not (ert--special-operator-p 'ert--special-operator-p))
620 (let ((b (cl-gensym))) 620 (cl-with-gensyms (b)
621 (should-not (ert--special-operator-p b)) 621 (should-not (ert--special-operator-p b))
622 (fset b 'if) 622 (fset b 'if)
623 (should (ert--special-operator-p b)))) 623 (should (ert--special-operator-p b))))
diff --git a/test/lisp/kmacro-tests.el b/test/lisp/kmacro-tests.el
index e4641cfc4e5..86adcbf3a30 100644
--- a/test/lisp/kmacro-tests.el
+++ b/test/lisp/kmacro-tests.el
@@ -24,6 +24,7 @@
24;;; Code: 24;;; Code:
25 25
26(require 'kmacro) 26(require 'kmacro)
27(require 'cl-lib)
27(require 'seq) 28(require 'seq)
28(require 'ert) 29(require 'ert)
29(require 'ert-x) 30(require 'ert-x)
@@ -157,8 +158,7 @@ Execute BODY, then check that the string VALUE was inserted
157into the current buffer at point." 158into the current buffer at point."
158 (declare (debug (stringp body)) 159 (declare (debug (stringp body))
159 (indent 1)) 160 (indent 1))
160 (let ((g-p (cl-gensym)) 161 (cl-with-gensyms (g-p g-bsize)
161 (g-bsize (cl-gensym)))
162 `(let ((,g-p (point)) 162 `(let ((,g-p (point))
163 (,g-bsize (buffer-size))) 163 (,g-bsize (buffer-size)))
164 ,@body 164 ,@body
@@ -172,7 +172,7 @@ VALUE and any text written to *Messages* during the execution,
172cause the current test to fail." 172cause the current test to fail."
173 (declare (debug (form body)) 173 (declare (debug (form body))
174 (indent 1)) 174 (indent 1))
175 (let ((g-captured-messages (cl-gensym))) 175 (cl-with-gensyms (g-captured-messages)
176 `(ert-with-message-capture ,g-captured-messages 176 `(ert-with-message-capture ,g-captured-messages
177 ,@body 177 ,@body
178 (should (string-match-p ,value ,g-captured-messages))))) 178 (should (string-match-p ,value ,g-captured-messages)))))
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el
index 51f7ddb25f0..fd3ecda2b72 100644
--- a/test/lisp/replace-tests.el
+++ b/test/lisp/replace-tests.el
@@ -528,8 +528,7 @@ then replace 3 matches of FROM with TO, and undo the last replacement.
528 528
529Return the last evalled form in BODY." 529Return the last evalled form in BODY."
530 (declare (indent 5) (debug (stringp stringp stringp form characterp body))) 530 (declare (indent 5) (debug (stringp stringp stringp form characterp body)))
531 (let ((text (gensym "text")) 531 (cl-with-gensyms (text count)
532 (count (gensym "count")))
533 `(let* ((,text ,input) 532 `(let* ((,text ,input)
534 (,count 0) 533 (,count 0)
535 (inhibit-message t)) 534 (inhibit-message t))