diff options
| author | Nicolas Petton | 2016-06-18 09:42:09 +0200 |
|---|---|---|
| committer | Nicolas Petton | 2016-06-18 10:10:00 +0200 |
| commit | 2aebb0dd1fc66ba8cacef3f734e9a046cbc04ad2 (patch) | |
| tree | 148912479fccd2d13d3799b3d84a697c100a57c0 /test | |
| parent | 9726856f297522b1773e8aadaec34dd1a8e68a14 (diff) | |
| download | emacs-2aebb0dd1fc66ba8cacef3f734e9a046cbc04ad2.tar.gz emacs-2aebb0dd1fc66ba8cacef3f734e9a046cbc04ad2.zip | |
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')
| -rw-r--r-- | test/lisp/emacs-lisp/map-tests.el | 8 |
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 20cb0f6b399..0af1c656e09 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. | |||
| 192 | (2 . b) | 192 | (2 . b) |
| 193 | (3 . c)))))) | 193 | (3 . c)))))) |
| 194 | 194 | ||
| 195 | (ert-deftest test-map-do () | ||
| 196 | (with-maps-do map | ||
| 197 | (let ((result nil)) | ||
| 198 | (map-do (lambda (k v) | ||
| 199 | (add-to-list 'result (list (int-to-string k) v))) | ||
| 200 | map) | ||
| 201 | (should (equal result '(("2" 5) ("1" 4) ("0" 3))))))) | ||
| 202 | |||
| 195 | (ert-deftest test-map-keys-apply () | 203 | (ert-deftest test-map-keys-apply () |
| 196 | (with-maps-do map | 204 | (with-maps-do map |
| 197 | (should (equal (map-keys-apply (lambda (k) (int-to-string k)) | 205 | (should (equal (map-keys-apply (lambda (k) (int-to-string k)) |