Commit 331d0e52 authored by Mark Oteiza's avatar Mark Oteiza
Browse files

Fix gensym

* lisp/subr.el (gensym): Actually implement the default prefix.
* test/lisp/subr-tests.el (subr-tests--gensym): New test.
parent 466df76f
......@@ -289,7 +289,7 @@ The name is made by appending `gensym-counter' to PREFIX.
PREFIX is a string, and defaults to \"g\"."
(let ((num (prog1 gensym-counter
(setq gensym-counter (1+ gensym-counter)))))
(make-symbol (format "%s%d" prefix num))))
(make-symbol (format "%s%d" (or prefix "g") num))))
(defun ignore (&rest _ignore)
"Do nothing and return nil.
......@@ -300,6 +300,12 @@ cf. Bug#25477."
(setq res (read-passwd "pass: " 'confirm (mapconcat #'string default "")))
(should (string= default res)))))
(ert-deftest subr-tests--gensym ()
"Test `gensym' behavior."
(should (equal (symbol-name (let ((gensym-counter 0)) (gensym)))
(should (eq (string-to-char (symbol-name (gensym))) ?g))
(should (eq (string-to-char (symbol-name (gensym "X"))) ?X)))
(provide 'subr-tests)
;;; subr-tests.el ends here
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment