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

    Test take and ntake
---
 compat-29.el    |  4 ++--
 compat-tests.el | 10 ++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/compat-29.el b/compat-29.el
index 25ac016f98..48470d49f7 100644
--- a/compat-29.el
+++ b/compat-29.el
@@ -79,7 +79,7 @@ WINDOW."
 
 ;;;; Defined in fns.c
 
-(compat-defun ntake (n list) ;; <UNTESTED>
+(compat-defun ntake (n list) ;; <OK>
   "Modify LIST to keep only the first N elements.
 If N is zero or negative, return nil.
 If N is greater or equal to the length of LIST, return LIST unmodified.
@@ -88,7 +88,7 @@ Otherwise, return LIST after truncating it."
                  (when cons (setcdr cons nil))
                  list)))
 
-(compat-defun take (n list) ;; <UNTESTED>
+(compat-defun take (n list) ;; <OK>
   "Return the first N elements of LIST.
 If N is zero or negative, return nil.
 If N is greater or equal to the length of LIST, return LIST (or a copy)."
diff --git a/compat-tests.el b/compat-tests.el
index 43b59836b0..2beb7a3c34 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -46,6 +46,16 @@
 (defmacro should-equal (a b)
   `(should (equal ,a ,b)))
 
+(ert-deftest ntake ()
+  (should-not (ntake 5 nil))
+  (should-equal '(1 2) (ntake 5 '(1 2)))
+  (should-equal '(1 2 3) (ntake 3 '(1 2 3 4))))
+
+(ert-deftest take ()
+  (should-not (take 5 nil))
+  (should-equal '(1 2) (take 5 '(1 2)))
+  (should-equal '(1 2 3) (take 3 '(1 2 3 4))))
+
 (ert-deftest format-message ()
   (should-equal (format-message "a=%s b=%s" 1 2) "a=1 b=2"))
 

Reply via email to