* lisp/subr.el (gensym): Actually implement the default prefix.
* test/lisp/subr-tests.el (subr-tests--gensym): New test.
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.
(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)))
+ "g0"))
+ (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