[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)))
- [elpa] externals/compat updated (8144719780 -> f0362f354c), ELPA Syncer, 2023/01/04
- [elpa] externals/compat 8ab4272a5d 5/7: Add thread-first and thread-last tests,
ELPA Syncer <=
- [elpa] externals/compat 9257871cb0 3/7: Test take and ntake, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 01ed1c6737 1/7: Drop broken func-arity, ELPA Syncer, 2023/01/04
- [elpa] externals/compat f0362f354c 7/7: Warn about untested functions, ELPA Syncer, 2023/01/04
- [elpa] externals/compat fc2ad0899d 6/7: Test buffer-local-boundp, ELPA Syncer, 2023/01/04
- [elpa] externals/compat b126fd50df 2/7: Mark a few functions as tested, ELPA Syncer, 2023/01/04
- [elpa] externals/compat 1d25236892 4/7: Use with-eval-after-load (24.4), ELPA Syncer, 2023/01/04