From: Matt Armstrong Date: Thu, 6 May 2021 11:29:33 +0000 (+0200) Subject: Add tests for `map-elt' X-Git-Tag: emacs-28.0.90~2590 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=49aebfe93c43b4b7f54b4c45bfb269a381e75836;p=emacs.git Add tests for `map-elt' * test/lisp/emacs-lisp/map-tests.el: Add (failing) tests for `map-elt' (bug#47572). --- diff --git a/test/lisp/emacs-lisp/map-tests.el b/test/lisp/emacs-lisp/map-tests.el index 67666d8e7e7..a04c6bef02a 100644 --- a/test/lisp/emacs-lisp/map-tests.el +++ b/test/lisp/emacs-lisp/map-tests.el @@ -476,5 +476,42 @@ Evaluate BODY for each created map." (list one two)) '(1 2))))) +(ert-deftest test-map-setf-alist-insert-key () + (let ((alist)) + (should (equal (setf (map-elt alist 'key) 'value) + 'value)) + (should (equal alist '((key . value)))))) + +(ert-deftest test-map-setf-alist-overwrite-key () + (let ((alist '((key . value1)))) + (should (equal (setf (map-elt alist 'key) 'value2) + 'value2)) + (should (equal alist '((key . value2)))))) + +(ert-deftest test-map-setf-plist-insert-key () + (let ((plist '(key value))) + (should (equal (setf (map-elt plist 'key2) 'value2) + 'value2)) + (should (equal plist '(key value key2 value2))))) + +(ert-deftest test-map-setf-plist-overwrite-key () + (let ((plist '(key value))) + (should (equal (setf (map-elt plist 'key) 'value2) + 'value2)) + (should (equal plist '(key value2))))) + +(ert-deftest test-hash-table-setf-insert-key () + (let ((ht (make-hash-table))) + (should (equal (setf (map-elt ht 'key) 'value) + 'value)) + (should (equal (map-elt ht 'key) 'value)))) + +(ert-deftest test-hash-table-setf-overwrite-key () + (let ((ht (make-hash-table))) + (puthash 'key 'value1 ht) + (should (equal (setf (map-elt ht 'key) 'value2) + 'value2)) + (should (equal (map-elt ht 'key) 'value2)))) + (provide 'map-tests) ;;; map-tests.el ends here