diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-09-01 10:32:49 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-09-01 10:32:49 +0200 |
commit | fffcc7ab25021fd9d73d50cf685a77777d38265c (patch) | |
tree | 0cd51e80fa954e44dba418afb432fa3e1a735cf2 /test/lisp/emacs-lisp | |
parent | 4a1505904e3606046c201f87deec1171f7d4d406 (diff) | |
download | emacs-fffcc7ab25021fd9d73d50cf685a77777d38265c.tar.gz emacs-fffcc7ab25021fd9d73d50cf685a77777d38265c.tar.bz2 emacs-fffcc7ab25021fd9d73d50cf685a77777d38265c.zip |
Fix (setf (map-elt map key) (my-func))
* lisp/emacs-lisp/map.el (map-elt): Ensure that the value isn't
referenced more than once (bug#50290).
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/map-tests.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/map-tests.el b/test/lisp/emacs-lisp/map-tests.el index 658ed2e7119..c0f0dbc92be 100644 --- a/test/lisp/emacs-lisp/map-tests.el +++ b/test/lisp/emacs-lisp/map-tests.el @@ -521,5 +521,14 @@ Evaluate BODY for each created map." 'value2)) (should (equal (map-elt ht 'key) 'value2)))) +(ert-deftest test-setf-map-with-function () + (let ((num 0) + (map nil)) + (setf (map-elt map 'foo) + (funcall (lambda () + (cl-incf num)))) + ;; Check that the function is only called once. + (should (= num 1)))) + (provide 'map-tests) ;;; map-tests.el ends here |