Permalink
Browse files

made keyword->symbol tolerant of non-keyword symbols

added test for keyword->symbol
  • Loading branch information...
1 parent 8c11a41 commit 83df0dd7a0c6ff9e982c1601b65b83647872bf29 @spacebat spacebat committed Dec 31, 2012
Showing with 19 additions and 1 deletion.
  1. +16 −0 kv-tests.el
  2. +3 −1 kv.el
View
16 kv-tests.el
@@ -141,6 +141,22 @@
(dotassq 'a.b.c '((a . ((b . ((c . 10)))))))
10)))
+(ert-deftest keyword->symbol ()
+ "Convert keyword into a symbol without the leading `:'"
+ (should
+ (eq
+ 'key
+ (keyword->symbol :key)))
+ (should
+ (eq
+ 'key
+ (keyword->symbol 'key)))
+ (let ((sym (gensym)))
+ (should
+ (eq
+ sym
+ (keyword->symbol sym)))))
+
(ert-deftest kvalist->plist ()
"Make alists into plists."
(should
View
4 kv.el
@@ -168,7 +168,9 @@ expression is true."
"A keyword is a symbol leading with a :.
Converting to a symbol means dropping the :."
- (intern (substring (symbol-name keyword) 1)))
+ (if (keywordp keyword)
+ (intern (substring (symbol-name keyword) 1))
+ keyword))
(defun kvplist->alist (plist)
"Convert PLIST to an alist.

0 comments on commit 83df0dd

Please sign in to comment.