diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2018-12-20 08:40:43 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2018-12-20 08:40:43 -0500 |
commit | f68f2eb47280cf92fdb41548e40b37e7a4a81e53 (patch) | |
tree | 069f12113b34c54c7b81f4dd388740b3f18458b5 /test/lisp/emacs-lisp | |
parent | 6a3c5f415b15531751dbbe4686950dbc15927866 (diff) | |
download | emacs-f68f2eb47280cf92fdb41548e40b37e7a4a81e53.tar.gz emacs-f68f2eb47280cf92fdb41548e40b37e7a4a81e53.tar.bz2 emacs-f68f2eb47280cf92fdb41548e40b37e7a4a81e53.zip |
* lisp/emacs-lisp/map.el: Add support for plists
(map--plist-p, map--plist-delete): New functions.
(map-elt, map-delete, map-length, map-into, map-put!, map-insert)
(map-apply, map-do): Handle the plist case.
* test/lisp/emacs-lisp/map-tests.el (with-maps-do): Add sample plist.
(test-map-put!): The behavior of map-put! is not the same for plists as
for alists.
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/map-tests.el | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test/lisp/emacs-lisp/map-tests.el b/test/lisp/emacs-lisp/map-tests.el index 4dd67d48d40..9b8f17b7ca7 100644 --- a/test/lisp/emacs-lisp/map-tests.el +++ b/test/lisp/emacs-lisp/map-tests.el @@ -38,17 +38,19 @@ Evaluate BODY for each created map. \(fn (var map) body)" (declare (indent 1) (debug (symbolp body))) (let ((alist (make-symbol "alist")) + (plist (make-symbol "plist")) (vec (make-symbol "vec")) (ht (make-symbol "ht"))) `(let ((,alist (list (cons 0 3) (cons 1 4) (cons 2 5))) + (,plist (list 0 3 1 4 2 5)) (,vec (vector 3 4 5)) (,ht (make-hash-table))) (puthash 0 3 ,ht) (puthash 1 4 ,ht) (puthash 2 5 ,ht) - (dolist (,var (list ,alist ,vec ,ht)) + (dolist (,var (list ,alist ,plist ,vec ,ht)) ,@body)))) (ert-deftest test-map-elt () @@ -86,7 +88,8 @@ Evaluate BODY for each created map. (with-maps-do map (map-put! map 2 'hello) (should (eq (map-elt map 2) 'hello)) - (if (not (hash-table-p map)) + (if (not (or (hash-table-p map) + (and (listp map) (not (listp (car map)))))) ;plist! (should-error (map-put! map 5 'value) ;; For vectors, it could arguably signal ;; map-not-inplace as well, but it currently doesn't. |