Expand tests for cl-incf and cl-decf

* test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-test-incf)
(cl-lib-test-decf): Expand tests.
This commit is contained in:
Stefan Kangas 2025-02-22 16:55:06 +01:00
parent ef8fdd269a
commit 8b6797fa01

View file

@ -63,21 +63,41 @@
(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)))