]> code.delx.au - gnu-emacs-elpa/commitdiff
Update seq.el to version 1.3
authorNicolas Petton <nicolas@petton.fr>
Mon, 9 Mar 2015 11:35:07 +0000 (12:35 +0100)
committerNicolas Petton <nicolas@petton.fr>
Mon, 9 Mar 2015 11:35:07 +0000 (12:35 +0100)
* packages/seq/seq.el: update to version 1.3
* packages/seq/tests/seq-tests.el: update to version 1.3

packages/seq/seq.el
packages/seq/tests/seq-tests.el

index 5366fd2e01138bf3cb535c24778733eece69ca79..59b91408d0941f0d8dc554a96cbf82eb96e34ded 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author: Nicolas Petton <nicolas@petton.fr>
 ;; Keywords: sequences
-;; Version: 1.2
+;; Version: 1.3
 ;; Package: seq
 
 ;; Maintainer: emacs-devel@gnu.org
@@ -172,7 +172,7 @@ The result is a sequence of the same type as SEQ."
   (if (listp seq)
       (sort (seq-copy seq) pred)
     (let ((result (seq-sort pred (append seq nil))))
-      (seq--into result (type-of seq)))))
+      (seq-into result (type-of seq)))))
 
 (defun seq-contains-p (seq elt &optional testfn)
   "Return the first element in SEQ that equals to ELT.
@@ -266,10 +266,11 @@ See also the function `nreverse', which is used more often."
                  seq)
         (if (listp seq)
             result
-          (seq--into result (type-of seq)))))))
+          (seq-into result (type-of seq)))))))
 
-(defun seq--into (seq type)
-  "Convert the sequence SEQ into a sequence of type TYPE."
+(defun seq-into (seq type)
+  "Convert the sequence SEQ into a sequence of type TYPE.
+TYPE can be one of the following symbols: vector, string or list."
   (pcase type
     (`vector (vconcat seq))
     (`string (concat seq))
index badb3267f436d975c53d0da10a4a2e54aca7007d..d3536b6f9a6930127c940429abdc1f33ee56e898 100644 (file)
@@ -228,5 +228,27 @@ Evaluate BODY for each created sequence.
     (should (equal (type-of (seq-reverse seq))
                    (type-of seq)))))
 
+(ert-deftest test-seq-into ()
+  (let* ((vector [1 2 3])
+         (list (seq-into vector 'list)))
+    (should (same-contents-p vector list))
+    (should (listp list)))
+  (let* ((list '(hello world))
+         (vector (seq-into list 'vector)))
+    (should (same-contents-p vector list))
+    (should (vectorp vector)))
+  (let* ((string "hello")
+         (list (seq-into string 'list)))
+    (should (same-contents-p string list))
+    (should (stringp string)))
+  (let* ((string "hello")
+         (vector (seq-into string 'vector)))
+    (should (same-contents-p string vector))
+    (should (stringp string)))
+  (let* ((list nil)
+         (vector (seq-into list 'vector)))
+    (should (same-contents-p list vector))
+    (should (vectorp vector))))
+
 (provide 'seq-tests)
 ;;; seq-tests.el ends here