]> git.eshelyaron.com Git - emacs.git/commitdiff
Add tests for cl-{incf,decf}
authorStefan Kangas <stefankangas@gmail.com>
Thu, 13 Aug 2020 20:02:18 +0000 (22:02 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Thu, 13 Aug 2020 20:04:59 +0000 (22:04 +0200)
* test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-test-incf)
(cl-lib-test-decf): New tests.

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

index 57b9d23efb0cc09ddcd3681309cd2b1ea6ebc6d4..40dd7e4eeb0e94fc48df3a1176540415f511d186 100644 (file)
     (should (= (cl-the integer (cl-incf side-effect)) 1))
     (should (= side-effect 1))))
 
+(ert-deftest cl-lib-test-incf ()
+  (let ((var 0))
+    (should (= (cl-incf var) 1))
+    (should (= var 1)))
+  (let ((alist))
+    (should (= (cl-incf (alist-get 'a alist 0)) 1))
+    (should (= (alist-get 'a alist 0) 1))))
+
+(ert-deftest cl-lib-test-decf ()
+  (let ((var 1))
+    (should (= (cl-decf var) 0))
+    (should (= var 0)))
+  (let ((alist))
+    (should (= (cl-decf (alist-get 'a alist 0)) -1))
+    (should (= (alist-get 'a alist 0) -1))))
+
 (ert-deftest cl-lib-test-plusp ()
   (should-not (cl-plusp -1.0e+INF))
   (should-not (cl-plusp -1.5e2))