]> code.delx.au - gnu-emacs/blobdiff - test/src/fns-tests.el
Test mapcan
[gnu-emacs] / test / src / fns-tests.el
index 848589692ea25a2bc77dd59a2428e8a29d5fd446..c533bad3cdcea5d03decf5dd819812a32ff41f17 100644 (file)
                    (backward-delete-char 1)
                    (buffer-hash))
                  (sha1 "foo"))))
+
+(ert-deftest fns-tests-mapcan ()
+  (should-error (mapcan))
+  (should-error (mapcan #'identity))
+  (should-error (mapcan #'identity (make-char-table 'foo)))
+  (should (equal (mapcan #'list '(1 2 3)) '(1 2 3)))
+  ;; `mapcan' is destructive
+  (let ((data '((foo) (bar))))
+    (should (equal (mapcan #'identity data) '(foo bar)))
+    (should (equal data                     '((foo bar) (bar))))))