diff options
| author | Stefan Monnier | 2018-12-20 08:40:43 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2018-12-20 08:40:43 -0500 |
| commit | f68f2eb47280cf92fdb41548e40b37e7a4a81e53 (patch) | |
| tree | 069f12113b34c54c7b81f4dd388740b3f18458b5 /test | |
| parent | 6a3c5f415b15531751dbbe4686950dbc15927866 (diff) | |
| download | emacs-f68f2eb47280cf92fdb41548e40b37e7a4a81e53.tar.gz 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')
| -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. | |||
| 38 | \(fn (var map) body)" | 38 | \(fn (var map) body)" |
| 39 | (declare (indent 1) (debug (symbolp body))) | 39 | (declare (indent 1) (debug (symbolp body))) |
| 40 | (let ((alist (make-symbol "alist")) | 40 | (let ((alist (make-symbol "alist")) |
| 41 | (plist (make-symbol "plist")) | ||
| 41 | (vec (make-symbol "vec")) | 42 | (vec (make-symbol "vec")) |
| 42 | (ht (make-symbol "ht"))) | 43 | (ht (make-symbol "ht"))) |
| 43 | `(let ((,alist (list (cons 0 3) | 44 | `(let ((,alist (list (cons 0 3) |
| 44 | (cons 1 4) | 45 | (cons 1 4) |
| 45 | (cons 2 5))) | 46 | (cons 2 5))) |
| 47 | (,plist (list 0 3 1 4 2 5)) | ||
| 46 | (,vec (vector 3 4 5)) | 48 | (,vec (vector 3 4 5)) |
| 47 | (,ht (make-hash-table))) | 49 | (,ht (make-hash-table))) |
| 48 | (puthash 0 3 ,ht) | 50 | (puthash 0 3 ,ht) |
| 49 | (puthash 1 4 ,ht) | 51 | (puthash 1 4 ,ht) |
| 50 | (puthash 2 5 ,ht) | 52 | (puthash 2 5 ,ht) |
| 51 | (dolist (,var (list ,alist ,vec ,ht)) | 53 | (dolist (,var (list ,alist ,plist ,vec ,ht)) |
| 52 | ,@body)))) | 54 | ,@body)))) |
| 53 | 55 | ||
| 54 | (ert-deftest test-map-elt () | 56 | (ert-deftest test-map-elt () |
| @@ -86,7 +88,8 @@ Evaluate BODY for each created map. | |||
| 86 | (with-maps-do map | 88 | (with-maps-do map |
| 87 | (map-put! map 2 'hello) | 89 | (map-put! map 2 'hello) |
| 88 | (should (eq (map-elt map 2) 'hello)) | 90 | (should (eq (map-elt map 2) 'hello)) |
| 89 | (if (not (hash-table-p map)) | 91 | (if (not (or (hash-table-p map) |
| 92 | (and (listp map) (not (listp (car map)))))) ;plist! | ||
| 90 | (should-error (map-put! map 5 'value) | 93 | (should-error (map-put! map 5 'value) |
| 91 | ;; For vectors, it could arguably signal | 94 | ;; For vectors, it could arguably signal |
| 92 | ;; map-not-inplace as well, but it currently doesn't. | 95 | ;; map-not-inplace as well, but it currently doesn't. |