[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] map 35c27cd: Throw an error when converting a map into an
From: |
Nicolas Petton |
Subject: |
[Emacs-diffs] map 35c27cd: Throw an error when converting a map into an unknown map type |
Date: |
Sat, 18 Apr 2015 14:37:59 +0000 |
branch: map
commit 35c27cd5818bede77279dc7e5cf1beec93766baa
Author: Nicolas Petton <address@hidden>
Commit: Nicolas Petton <address@hidden>
Throw an error when converting a map into an unknown map type
* 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 | 3 ++-
test/automated/map-test.el | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el
index fec0634..7d839f8 100644
--- a/lisp/emacs-lisp/map.el
+++ b/lisp/emacs-lisp/map.el
@@ -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.
diff --git a/test/automated/map-test.el b/test/automated/map-test.el
index 8a12be8..ea7b0af 100644
--- a/test/automated/map-test.el
+++ b/test/automated/map-test.el
@@ -318,7 +318,8 @@
(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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] map 35c27cd: Throw an error when converting a map into an unknown map type,
Nicolas Petton <=