From 092a0611a14c9523585ade2f99fa8fcddf675594 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 22 Feb 2025 16:55:06 +0100 Subject: [PATCH] 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. (cherry picked from commit 8b6797fa01bf8c8c64bd1f72c1e2475bf2331ad9) --- test/lisp/emacs-lisp/cl-lib-tests.el | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el index ff19ec74a43..376566958a0 100644 --- a/test/lisp/emacs-lisp/cl-lib-tests.el +++ b/test/lisp/emacs-lisp/cl-lib-tests.el @@ -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))) -- 2.39.5