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

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

[elpa] externals/compat 35072b3d25 22/27: Fix if-let and add tests


From: ELPA Syncer
Subject: [elpa] externals/compat 35072b3d25 22/27: Fix if-let and add tests
Date: Sat, 5 Mar 2022 04:57:28 -0500 (EST)

branch: externals/compat
commit 35072b3d252bbabf07d132bfdabe3933d987a3ce
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Fix if-let and add tests
---
 compat-25.el    |  2 +-
 compat-tests.el | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/compat-25.el b/compat-25.el
index da084b807e..0e107cb6c5 100644
--- a/compat-25.el
+++ b/compat-25.el
@@ -169,7 +169,7 @@ with an old syntax that accepted only one binding."
              (not (listp (car spec))))
     ;; Adjust the single binding case
     (setq spec (list spec)))
-  `(compat--if-let* ,spec ,then ,@(macroexp-unprogn else)))
+  `(compat--if-let* ,spec ,then ,(macroexp-progn else)))
 
 (compat-defmacro when-let (spec &rest body)
   "Bind variables according to SPEC and conditionally evaluate BODY.
diff --git a/compat-tests.el b/compat-tests.el
index 6d781d25ca..bb959dc711 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1275,6 +1275,19 @@ the compatibility function."
   (should-not
    (compat--if-let* (((= 5 6))) t nil)))
 
+(ert-deftest compat-if-let ()
+  "Check if `compat--if-let' was implemented properly."
+  (should (compat--if-let ((e (memq 0 '(1 2 3 0 5 6))))
+              e))
+  (should-not (compat--if-let ((e (memq 0 '(1 2 3 5 6)))
+                               (d (memq 0 '(1 2 3 0 5 6))))
+                  t))
+  (should-not (compat--if-let ((d (memq 0 '(1 2 3 0 5 6)))
+                               (e (memq 0 '(1 2 3 5 6))))
+                  t))
+  (should-not
+   (compat--if-let (((= 5 6))) t nil)))
+
 (ert-deftest compat-and-let* ()
   "Check if `compat--if-let*' was implemented properly."
   (should                               ;trivial body



reply via email to

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