summaryrefslogtreecommitdiff
path: root/test/lisp
diff options
context:
space:
mode:
authorNicolas Petton <nicolas@petton.fr>2016-06-18 09:42:09 +0200
committerNicolas Petton <nicolas@petton.fr>2016-06-18 10:10:00 +0200
commit2aebb0dd1fc66ba8cacef3f734e9a046cbc04ad2 (patch)
tree148912479fccd2d13d3799b3d84a697c100a57c0 /test/lisp
parent9726856f297522b1773e8aadaec34dd1a8e68a14 (diff)
Add new function map-do
* lisp/emacs-lisp/map.el (map-do, map--do-alist, map--do-array): New functions. * test/lisp/emacs-lisp/map-tests.el: Add a unit test for map-do.
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/emacs-lisp/map-tests.el8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/map-tests.el b/test/lisp/emacs-lisp/map-tests.el
index 20cb0f6b39..0af1c656e0 100644
--- a/test/lisp/emacs-lisp/map-tests.el
+++ b/test/lisp/emacs-lisp/map-tests.el
@@ -192,6 +192,14 @@ Evaluate BODY for each created map.
(2 . b)
(3 . c))))))
+(ert-deftest test-map-do ()
+ (with-maps-do map
+ (let ((result nil))
+ (map-do (lambda (k v)
+ (add-to-list 'result (list (int-to-string k) v)))
+ map)
+ (should (equal result '(("2" 5) ("1" 4) ("0" 3)))))))
+
(ert-deftest test-map-keys-apply ()
(with-maps-do map
(should (equal (map-keys-apply (lambda (k) (int-to-string k))