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

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

[elpa] externals/compat 8ab4272a5d 5/7: Add thread-first and thread-last


From: ELPA Syncer
Subject: [elpa] externals/compat 8ab4272a5d 5/7: Add thread-first and thread-last tests
Date: Wed, 4 Jan 2023 13:57:28 -0500 (EST)

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

    Add thread-first and thread-last tests
---
 compat-25.el    |  4 ++--
 compat-tests.el | 30 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/compat-25.el b/compat-25.el
index 9ad856f39d..1a01b57fb8 100644
--- a/compat-25.el
+++ b/compat-25.el
@@ -176,7 +176,7 @@ The variable list SPEC is the same as in `if-let'."
 
 ;;;; Defined in subr-x.el
 
-(compat-defmacro thread-first (&rest forms) ;; <UNTESTED>
+(compat-defmacro thread-first (&rest forms) ;; <OK>
   "Thread FORMS elements as the first argument of their successor.
 Example:
     (thread-first
@@ -200,7 +200,7 @@ threading."
                          (cdr form))))
     body))
 
-(compat-defmacro thread-last (&rest forms) ;; <UNTESTED>
+(compat-defmacro thread-last (&rest forms) ;; <OK>
   "Thread FORMS elements as the last argument of their successor.
 Example:
     (thread-last
diff --git a/compat-tests.el b/compat-tests.el
index 2beb7a3c34..41e25bc5fb 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -46,6 +46,36 @@
 (defmacro should-equal (a b)
   `(should (equal ,a ,b)))
 
+(ert-deftest thread-first ()
+  (should-equal (thread-first (+ 40 2)) 42)
+  (should-equal (thread-first
+                   5
+                   (+ 20)
+                   (/ 25)
+                   -
+                   (+ 40)) 39)
+  (should-equal (thread-first
+                   "this-is-a-string"
+                   (split-string "-")
+                   (nbutlast 2)
+                   (append (list "good")))
+                 (list "this" "is" "good")))
+
+(ert-deftest thread-last ()
+  (should-equal (thread-last (+ 40 2)) 42)
+  (should-equal (thread-last
+                   5
+                   (+ 20)
+                   (/ 25)
+                   -
+                   (+ 40)) 39)
+  (should-equal (thread-last
+                   (list 1 -2 3 -4 5)
+                   (mapcar #'abs)
+                   (cl-reduce #'+)
+                   (format "abs sum is: %s"))
+                 "abs sum is: 15"))
+
 (ert-deftest ntake ()
   (should-not (ntake 5 nil))
   (should-equal '(1 2) (ntake 5 '(1 2)))



reply via email to

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