diff options
| author | Stefan Kangas | 2025-02-22 17:32:31 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2025-02-23 00:38:22 +0100 |
| commit | 95fee880e45184f4820e9704b75887ef2d91bd01 (patch) | |
| tree | 09afd4a8d6f9ccf0f2cec36e4f604deaf040c728 /test | |
| parent | 44a1c4a9aea54d6542bcf0c231b080f0ed023229 (diff) | |
| download | emacs-95fee880e45184f4820e9704b75887ef2d91bd01.tar.gz emacs-95fee880e45184f4820e9704b75887ef2d91bd01.zip | |
New macros incf and decf
* lisp/emacs-lisp/cl-lib.el (cl-incf, cl-decf): Move macros from here...
* lisp/emacs-lisp/gv.el (incf, decf): ...to here. Make old names into
aliases, documented as deprecated.
* lisp/obsolete/cl.el: Don't alias incf and decf.
* test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-test-incf)
(cl-lib-test-decf): Move tests from here...
* test/lisp/emacs-lisp/gv-tests.el (gv-incf, gv-decf): ...to here.
* doc/lispref/numbers.texi (Arithmetic Operations):
* lisp/emacs-lisp/shortdoc.el (number): Document incf and decf.
* doc/lispref/variables.texi (Multisession Variables):
* doc/misc/cl.texi (Organization, Modify Macros, Modify Macros)
(Modify Macros, Macro Bindings, For Clauses, Property Lists)
(Structures, Efficiency Concerns, Obsolete Setf Customization): Delete
cl-incf and cl-decf documentation, moving any relevant parts to lispref.
Delete some parts that seem to primarily regard implementation details
that do not warrant inclusion in lispref. Update all examples to use
incf/decf.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/cl-lib-tests.el | 36 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/gv-tests.el | 36 |
2 files changed, 36 insertions, 36 deletions
diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el index 376566958a0..d7c38b73432 100644 --- a/test/lisp/emacs-lisp/cl-lib-tests.el +++ b/test/lisp/emacs-lisp/cl-lib-tests.el | |||
| @@ -63,42 +63,6 @@ | |||
| 63 | (should (equal (cl-multiple-value-list nil) nil)) | 63 | (should (equal (cl-multiple-value-list nil) nil)) |
| 64 | (should (equal (cl-multiple-value-list (list 1 2 3)) '(1 2 3)))) | 64 | (should (equal (cl-multiple-value-list (list 1 2 3)) '(1 2 3)))) |
| 65 | 65 | ||
| 66 | (defvar cl-lib-test--special 0) | ||
| 67 | |||
| 68 | (ert-deftest cl-lib-test-incf () | ||
| 69 | (setq cl-lib-test--special 0) | ||
| 70 | (should (= (cl-incf cl-lib-test--special) 1)) | ||
| 71 | (should (= cl-lib-test--special 1)) | ||
| 72 | (should (= (cl-incf cl-lib-test--special 9) 10)) | ||
| 73 | (should (= cl-lib-test--special 10)) | ||
| 74 | (let ((var 0)) | ||
| 75 | (should (= (cl-incf var) 1)) | ||
| 76 | (should (= var 1)) | ||
| 77 | (should (= (cl-incf var 9) 10)) | ||
| 78 | (should (= var 10))) | ||
| 79 | (let ((alist)) | ||
| 80 | (should (= (cl-incf (alist-get 'a alist 0)) 1)) | ||
| 81 | (should (= (alist-get 'a alist 0) 1)) | ||
| 82 | (should (= (cl-incf (alist-get 'a alist 0) 9) 10)) | ||
| 83 | (should (= (alist-get 'a alist 0) 10)))) | ||
| 84 | |||
| 85 | (ert-deftest cl-lib-test-decf () | ||
| 86 | (setq cl-lib-test--special 0) | ||
| 87 | (should (= (cl-decf cl-lib-test--special) -1)) | ||
| 88 | (should (= cl-lib-test--special -1)) | ||
| 89 | (should (= (cl-decf cl-lib-test--special 9) -10)) | ||
| 90 | (should (= cl-lib-test--special -10)) | ||
| 91 | (let ((var 1)) | ||
| 92 | (should (= (cl-decf var) 0)) | ||
| 93 | (should (= var 0)) | ||
| 94 | (should (= (cl-decf var 10) -10)) | ||
| 95 | (should (= var -10))) | ||
| 96 | (let ((alist)) | ||
| 97 | (should (= (cl-decf (alist-get 'a alist 0)) -1)) | ||
| 98 | (should (= (alist-get 'a alist 0) -1)) | ||
| 99 | (should (= (cl-decf (alist-get 'a alist 0) 9) -10)) | ||
| 100 | (should (= (alist-get 'a alist 0) -10)))) | ||
| 101 | |||
| 102 | (ert-deftest cl-digit-char-p () | 66 | (ert-deftest cl-digit-char-p () |
| 103 | (should (eql 3 (cl-digit-char-p ?3))) | 67 | (should (eql 3 (cl-digit-char-p ?3))) |
| 104 | (should (eql 10 (cl-digit-char-p ?a 11))) | 68 | (should (eql 10 (cl-digit-char-p ?a 11))) |
diff --git a/test/lisp/emacs-lisp/gv-tests.el b/test/lisp/emacs-lisp/gv-tests.el index 5ea386e0b5d..892af4bfab1 100644 --- a/test/lisp/emacs-lisp/gv-tests.el +++ b/test/lisp/emacs-lisp/gv-tests.el | |||
| @@ -163,6 +163,42 @@ its getter (Bug#41853)." | |||
| 163 | (eval-buffer)))) | 163 | (eval-buffer)))) |
| 164 | (should (equal (get 'gv-setter-edebug 'gv-setter-edebug-prop) '(123)))) | 164 | (should (equal (get 'gv-setter-edebug 'gv-setter-edebug-prop) '(123)))) |
| 165 | 165 | ||
| 166 | (defvar gv-test--special 0) | ||
| 167 | |||
| 168 | (ert-deftest gv-incf () | ||
| 169 | (setq gv-test--special 0) | ||
| 170 | (should (= (incf gv-test--special) 1)) | ||
| 171 | (should (= gv-test--special 1)) | ||
| 172 | (should (= (incf gv-test--special 9) 10)) | ||
| 173 | (should (= gv-test--special 10)) | ||
| 174 | (let ((var 0)) | ||
| 175 | (should (= (incf var) 1)) | ||
| 176 | (should (= var 1)) | ||
| 177 | (should (= (incf var 9) 10)) | ||
| 178 | (should (= var 10))) | ||
| 179 | (let ((alist)) | ||
| 180 | (should (= (incf (alist-get 'a alist 0)) 1)) | ||
| 181 | (should (= (alist-get 'a alist 0) 1)) | ||
| 182 | (should (= (incf (alist-get 'a alist 0) 9) 10)) | ||
| 183 | (should (= (alist-get 'a alist 0) 10)))) | ||
| 184 | |||
| 185 | (ert-deftest gv-decf () | ||
| 186 | (setq gv-test--special 0) | ||
| 187 | (should (= (decf gv-test--special) -1)) | ||
| 188 | (should (= gv-test--special -1)) | ||
| 189 | (should (= (decf gv-test--special 9) -10)) | ||
| 190 | (should (= gv-test--special -10)) | ||
| 191 | (let ((var 1)) | ||
| 192 | (should (= (decf var) 0)) | ||
| 193 | (should (= var 0)) | ||
| 194 | (should (= (decf var 10) -10)) | ||
| 195 | (should (= var -10))) | ||
| 196 | (let ((alist)) | ||
| 197 | (should (= (decf (alist-get 'a alist 0)) -1)) | ||
| 198 | (should (= (alist-get 'a alist 0) -1)) | ||
| 199 | (should (= (decf (alist-get 'a alist 0) 9) -10)) | ||
| 200 | (should (= (alist-get 'a alist 0) -10)))) | ||
| 201 | |||
| 166 | (ert-deftest gv-plist-get () | 202 | (ert-deftest gv-plist-get () |
| 167 | ;; Simple `setf' usage for `plist-get'. | 203 | ;; Simple `setf' usage for `plist-get'. |
| 168 | (let ((target (list :a "a" :b "b" :c "c"))) | 204 | (let ((target (list :a "a" :b "b" :c "c"))) |