branch: externals/compat commit 35072b3d252bbabf07d132bfdabe3933d987a3ce Author: Philip Kaludercic <phil...@posteo.net> Commit: Philip Kaludercic <phil...@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