branch: externals/compat
commit 79d3562f6d9d88761c5f2356a9f272c58857ed6a
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>

    Add when-let test
---
 compat-tests.el | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/compat-tests.el b/compat-tests.el
index 5ca6301147..3a2e995d2b 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1195,6 +1195,16 @@
   (should-equal "else"
    (if-let* (((= 5 6))) "then" "else")))
 
+(ert-deftest when-let ()
+  (should-equal "last"
+                (when-let (e (memq 0 '(1 2 3 0 5 6)))
+                  "first" "last"))
+  (should-equal "last" (when-let ((e (memq 0 '(1 2 3 0 5 6))))
+                         "first" "last"))
+  (should-not (when-let ((e (memq 0 '(1 2 3 5 6)))
+                               (d (memq 0 '(1 2 3 0 5 6))))
+                  "first" "last")))
+
 (ert-deftest if-let ()
   (should (if-let (e (memq 0 '(1 2 3 0 5 6)))
               e))

Reply via email to