diff options
author | Matt Armstrong <matt@rfc20.org> | 2021-05-06 13:29:33 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-05-06 13:32:04 +0200 |
commit | 49aebfe93c43b4b7f54b4c45bfb269a381e75836 (patch) | |
tree | cb3368402320beb1dfcf7111e260a75df6b6f70f /test/lisp/emacs-lisp/map-tests.el | |
parent | 5ec4a3dbbc81ef9ed51065189a19689c351e0e8d (diff) | |
download | emacs-49aebfe93c43b4b7f54b4c45bfb269a381e75836.tar.gz |
Add tests for `map-elt'
* test/lisp/emacs-lisp/map-tests.el: Add (failing) tests for `map-elt'
(bug#47572).
Diffstat (limited to 'test/lisp/emacs-lisp/map-tests.el')
-rw-r--r-- | test/lisp/emacs-lisp/map-tests.el | 37 |
1 files changed, 37 insertions, 0 deletions
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 |