bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25826: 26.0.50; cl-mapc and cl-mapl do needless consing


From: npostavs
Subject: bug#25826: 26.0.50; cl-mapc and cl-mapl do needless consing
Date: Wed, 22 Feb 2017 20:55:58 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Tino Calancha <address@hidden> writes:
> It's tricky to write a test to check if cl-mapc/cl-mapl over cons.
> Thus, i have written tests that just ensure the return values
> are as expected.

We should check that the args are consp at least:

>From aed9f2462f7825b1dddbdf20fa5aa9b74a51ca72 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <address@hidden>
Date: Wed, 22 Feb 2017 20:46:12 -0500
Subject: [PATCH] fixup! Prevent for consing in cl-mapc and cl-mapl

---
 test/lisp/emacs-lisp/cl-extra-tests.el | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/test/lisp/emacs-lisp/cl-extra-tests.el 
b/test/lisp/emacs-lisp/cl-extra-tests.el
index 82b2206a6c..5b2371e7b9 100644
--- a/test/lisp/emacs-lisp/cl-extra-tests.el
+++ b/test/lisp/emacs-lisp/cl-extra-tests.el
@@ -39,9 +39,9 @@
   (let ((lst '(a b c))
         (lst2 '(d e f))
         (lst3 '(1 2 3))
-        (fn1 (lambda (x) nil))
-        (fn2 (lambda (x y) nil))
-        (fn3 (lambda (x y z) nil)))
+        (fn1 (lambda (_x) nil))
+        (fn2 (lambda (_x _y) nil))
+        (fn3 (lambda (_x _y _z) nil)))
     (should (equal lst (cl-mapc fn1 lst)))
     (should (equal lst (cl-mapc fn2 lst lst2)))
     (should (equal lst (cl-mapc fn3 lst lst2 lst3)))))
@@ -50,9 +50,9 @@
   (let ((lst '(a b c))
         (lst2 '(d e f))
         (lst3 '(1 2 3))
-        (fn1 (lambda (x) nil))
-        (fn2 (lambda (x y) nil))
-        (fn3 (lambda (x y z) nil)))
+        (fn1 (lambda (x) (should (consp x))))
+        (fn2 (lambda (x y) (should (and (consp x) (consp y)))))
+        (fn3 (lambda (x y z) (should (and (consp x) (consp y) (consp z))))))
     (should (equal lst (cl-mapl fn1 lst)))
     (should (equal lst (cl-mapl fn2 lst lst2)))
     (should (equal lst (cl-mapl fn3 lst lst2 lst3)))))
@@ -62,8 +62,8 @@
         (lst2 '(d e f))
         (lst3 '(1 2 3))
         (fn1 (lambda (x) x))
-        (fn2 (lambda (x y) y))
-        (fn3 (lambda (x y z) z)))
+        (fn2 (lambda (_x y) y))
+        (fn3 (lambda (_x _y z) z)))
     (should (equal lst (cl-mapcar fn1 lst)))
     (should (equal lst2 (cl-mapcar fn2 lst lst2)))
     (should (equal lst3 (cl-mapcar fn3 lst lst2 lst3)))))
@@ -73,8 +73,8 @@
         (lst2 '(d e f))
         (lst3 '(1 2 3))
         (fn1 (lambda (x) x))
-        (fn2 (lambda (x y) y))
-        (fn3 (lambda (x y z) (string-to-char (format "%S" x)))))
+        (fn2 (lambda (_x y) y))
+        (fn3 (lambda (x _y _z) (string-to-char (format "%S" x)))))
     (should (equal lst (cl-map 'list fn1 lst)))
     (should (equal (vconcat lst2) (cl-map 'vector fn2 lst lst2)))
     (should (equal (mapconcat (lambda (x) (format "%S" x)) lst "")
@@ -84,9 +84,9 @@
   (let ((lst '(a b c))
         (lst2 '(d e f))
         (lst3 '(1 2 3))
-        (fn1 (lambda (x) x))
-        (fn2 (lambda (x y) y))
-        (fn3 (lambda (x y z) z)))
+        (fn1 (lambda (x) (should (consp x)) x))
+        (fn2 (lambda (x y) (should (and (consp x) (consp y))) y))
+        (fn3 (lambda (x y z) (should (and (consp x) (consp y) (consp z))) z)))
     (should (equal (list lst (cdr lst) (cddr lst))
                    (cl-maplist fn1 lst)))
     (should (equal (list lst2 (cdr lst2) (cddr lst2))
-- 
2.11.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]