]> git.eshelyaron.com Git - emacs.git/commitdiff
Expand tests for cl-incf and cl-decf
authorStefan Kangas <stefankangas@gmail.com>
Sat, 22 Feb 2025 15:55:06 +0000 (16:55 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sun, 23 Feb 2025 08:17:59 +0000 (09:17 +0100)
* test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-test-incf)
(cl-lib-test-decf): Expand tests.

(cherry picked from commit 8b6797fa01bf8c8c64bd1f72c1e2475bf2331ad9)

test/lisp/emacs-lisp/cl-lib-tests.el

index ff19ec74a43966006bf1f06cab9ce6dd3759c11b..376566958a01d59fc86921710a6761759473c842 100644 (file)
   (should (equal (cl-multiple-value-list nil) nil))
   (should (equal (cl-multiple-value-list (list 1 2 3)) '(1 2 3))))
 
+(defvar cl-lib-test--special 0)
+
 (ert-deftest cl-lib-test-incf ()
+  (setq cl-lib-test--special 0)
+  (should (= (cl-incf cl-lib-test--special) 1))
+  (should (= cl-lib-test--special 1))
+  (should (= (cl-incf cl-lib-test--special 9) 10))
+  (should (= cl-lib-test--special 10))
   (let ((var 0))
     (should (= (cl-incf var) 1))
-    (should (= var 1)))
+    (should (= var 1))
+    (should (= (cl-incf var 9) 10))
+    (should (= var 10)))
   (let ((alist))
     (should (= (cl-incf (alist-get 'a alist 0)) 1))
-    (should (= (alist-get 'a alist 0) 1))))
+    (should (= (alist-get 'a alist 0) 1))
+    (should (= (cl-incf (alist-get 'a alist 0) 9) 10))
+    (should (= (alist-get 'a alist 0) 10))))
 
 (ert-deftest cl-lib-test-decf ()
+  (setq cl-lib-test--special 0)
+  (should (= (cl-decf cl-lib-test--special) -1))
+  (should (= cl-lib-test--special -1))
+  (should (= (cl-decf cl-lib-test--special 9) -10))
+  (should (= cl-lib-test--special -10))
   (let ((var 1))
     (should (= (cl-decf var) 0))
-    (should (= var 0)))
+    (should (= var 0))
+    (should (= (cl-decf var 10) -10))
+    (should (= var -10)))
   (let ((alist))
     (should (= (cl-decf (alist-get 'a alist 0)) -1))
-    (should (= (alist-get 'a alist 0) -1))))
+    (should (= (alist-get 'a alist 0) -1))
+    (should (= (cl-decf (alist-get 'a alist 0) 9) -10))
+    (should (= (alist-get 'a alist 0) -10))))
 
 (ert-deftest cl-digit-char-p ()
   (should (eql 3 (cl-digit-char-p ?3)))