emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/compat 69a69fa23e: while-let: Test the single binding c


From: ELPA Syncer
Subject: [elpa] externals/compat 69a69fa23e: while-let: Test the single binding case
Date: Fri, 13 Jan 2023 00:57:40 -0500 (EST)

branch: externals/compat
commit 69a69fa23ea01406f8b5b43adf3de885e668cced
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    while-let: Test the single binding case
    
    bug#60758
---
 compat-25.el    |  3 +--
 compat-29.el    |  3 +++
 compat-tests.el | 14 ++++++++++----
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/compat-25.el b/compat-25.el
index 42fa9e0a5a..bc9449b7f0 100644
--- a/compat-25.el
+++ b/compat-25.el
@@ -120,8 +120,7 @@ with an old syntax that accepted only one binding."
            (debug ([&or (symbolp form)
                         (&rest [&or symbolp (symbolp form) (form)])]
                    body)))
-  (when (and (<= (length spec) 2)
-             (not (listp (car spec))))
+  (when (and (<= (length spec) 2) (not (listp (car spec))))
     ;; Adjust the single binding case
     (setq spec (list spec)))
   (let ((empty (make-symbol "s"))
diff --git a/compat-29.el b/compat-29.el
index bcee2bd975..819988b3a9 100644
--- a/compat-29.el
+++ b/compat-29.el
@@ -333,6 +333,9 @@ If all bindings are non-nil, eval BODY and repeat.
 
 The variable list SPEC is the same as in `if-let'."
   (declare (indent 1) (debug if-let))
+  (when (and (<= (length spec) 2) (not (listp (car spec))))
+    ;; Adjust the single binding case
+    (setq spec (list spec)))
   (let ((done (gensym "done")))
     `(catch ',done
        (while t
diff --git a/compat-tests.el b/compat-tests.el
index f03d6c6e90..854903cd72 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -46,6 +46,10 @@
 (defmacro should-equal (a b)
   `(should (equal ,a ,b)))
 
+(defmacro compat-tests--if (cond then &rest else)
+  (declare (indent 2))
+  (if (eval cond t) then (macroexp-progn else)))
+
 (ert-deftest compat-loaded-features ()
   (let ((version 0))
     (while (< version 30)
@@ -1563,6 +1567,12 @@
   (should-not (boundp 'compat-tests--dlet2)))
 
 (ert-deftest while-let ()
+  ;; FIXME: Reenable this test on Emacs 29 and 30 (bug#60758)
+  (compat-tests--if (< emacs-major-version 29)
+    (let ((list '(1 2 3 4)) rev)
+      (while-let (x (pop list))
+        (push x rev))
+      (should-equal '(4 3 2 1) rev)))
   (let ((first '(1 2 3 4)) (second '(a b c)) zipped)
     (while-let ((x (pop first)) (y (pop second)))
       (push (cons x y) zipped))
@@ -1592,10 +1602,6 @@
   (should-equal "else"
    (if-let* (((= 5 6))) "then" "else")))
 
-(defmacro compat-tests--if (cond then &rest else)
-  (declare (indent 2))
-  (if cond then (macroexp-progn else)))
-
 (ert-deftest when-let ()
   ;; FIXME Broken on Emacs 25
   (compat-tests--if (= emacs-major-version 25)



reply via email to

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