From 2aebb0dd1fc66ba8cacef3f734e9a046cbc04ad2 Mon Sep 17 00:00:00 2001 From: Nicolas Petton Date: Sat, 18 Jun 2016 09:42:09 +0200 Subject: 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. --- test/lisp/emacs-lisp/map-tests.el | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/lisp') 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)) -- cgit v1.2.3