]> git.eshelyaron.com Git - emacs.git/commitdiff
Throw an error when converting a map into an unknown map type
authorNicolas Petton <nicolas@petton.fr>
Sat, 18 Apr 2015 14:35:43 +0000 (16:35 +0200)
committerNicolas Petton <nicolas@petton.fr>
Sat, 18 Apr 2015 14:35:43 +0000 (16:35 +0200)
* lisp/emacs-lisp/map.el (map-into): Throw an error if type is not valid.
* test/automated/map-test.el: Add a regression test.

lisp/emacs-lisp/map.el
test/automated/map-test.el

index fec06343f7ca0d43153f5996064b4862ba48fb0e..7d839f822d286ec1aa97576771ca4dfca147271d 100644 (file)
@@ -193,7 +193,8 @@ MAP can be a list, hash-table or array."
 TYPE can be one of the following symbols: list or hash-table."
   (pcase type
     (`list (map-pairs map))
-    (`hash-table (map--into-hash-table map))))
+    (`hash-table (map--into-hash-table map))
+    (t (error "Not a map type name: %s" type))))
 
 (defmacro map--dispatch (spec &rest args)
   "Evaluate one of the provided forms depending on the type of MAP.
index 8a12be84aa16725a40d86571a475d780e5f7d777..ea7b0af3f469d8d1f90384a9957160bafcd106c2 100644 (file)
     (assert (equal (map-values (map-into (map-into ht 'list) 'hash-table))
                    (map-values ht)))
     (assert (null (map-into nil 'list)))
-    (assert (map-empty-p (map-into nil 'hash-table)))))
+    (assert (map-empty-p (map-into nil 'hash-table)))
+    (should-error (map-into [1 2 3] 'string))))
 
 (provide 'map-tests)
 ;;; map-tests.el ends here