* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-reify-function):
* test/lisp/emacs-lisp/cl-extra-tests.el (cl-getf):
* test/lisp/emacs-lisp/cl-macs-tests.el
(cl-macs-loop-for-as-arith-order-side-effects)
(cl-macs-loop-for-as-equals-then, cl-macs-loop-do, cl-macs-loop-finally)
(cl-macs-loop-in-ref, cl-macs-loop-being-elements-of-ref)
(cl-macs-test--symbol-macrolet, cl-the):
* test/lisp/emacs-lisp/cl-seq-tests.el (cl-lib-test-remove)
(cl-lib-test-remove-if-not):
* test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
(edebug-test-code-range):
* test/lisp/emacs-lisp/edebug-tests.el (edebug-tests-deduplicate):
* test/lisp/emacs-lisp/generator-tests.el (cps-while-incf):
(cps-test-iter-cleanup-once-only):
* test/lisp/emacs-lisp/hierarchy-tests.el
(hierarchy-labelfn-button-if-does-not-button-unless-condition)
(hierarchy-labelfn-button-if-does-button-when-condition):
* test/lisp/emacs-lisp/let-alist-tests.el (let-alist-evaluate-once):
* test/lisp/emacs-lisp/lisp-mode-tests.el
(indent-sexp, lisp-indent-region):
* test/lisp/emacs-lisp/map-tests.el (test-map-elt-gv)
(test-setf-map-with-function):
* test/lisp/emacs-lisp/multisession-tests.el (multi-test-sqlite-simple)
(multi-test-sqlite-busy, multi-test-files-simple)
(multi-test-files-busy):
* test/lisp/emacs-lisp/oclosure-tests.el
(oclosure-test, oclosure-test-mutate):
* test/lisp/emacs-lisp/track-changes-tests.el
(track-changes-tests--random):
* test/lisp/files-tests.el (files-tests--with-buffer-offer-save):
* test/lisp/net/shr-tests.el (shr-test/zoom-image):
* test/lisp/replace-tests.el (replace-tests-with-undo):
* test/src/buffer-tests.el (test-overlay-randomly):
* test/src/data-tests.el (test-bool-vector-bv-from-hex-string):
* test/src/fns-tests.el (fns-tests-sort):
* test/src/json-tests.el (json-insert/signal, json-insert/throw):
* test/src/minibuf-tests.el (minibuf-tests--strings-to-symbol-alist)
(minibuf-tests--strings-to-string-alist)
(minibuf-tests--strings-to-string-hashtable)
(minibuf-tests--strings-to-symbol-hashtable):
* test/src/process-tests.el (make-process/file-handler/found): Prefer
incf to cl-incf.
(cherry picked from commit
042dc5929b706b5fbc0ea8ada6014661d44a1b53)
(cl-letf ((lexical-binding t)
((symbol-function 'counter) nil))
(let ((x 0))
- (defun counter () (cl-incf x))
+ (defun counter () (incf x))
(should (equal (counter) 1))
(should (equal (counter) 2))
;; byte compiling should not cause counter to always return the
(should (eq (cl-getf plist 'x) 1))
(should-not (cl-getf plist 'y :none))
(should (eq (cl-getf plist 'z :none) :none))
- (should (eq (cl-incf (cl-getf plist 'x 10) 2) 3))
+ (should (eq (incf (cl-getf plist 'x 10) 2) 3))
(should (equal plist '(x 3 y nil)))
- (should-error (cl-incf (cl-getf plist 'y 10) 4) :type 'wrong-type-argument)
+ (should-error (incf (cl-getf plist 'y 10) 4) :type 'wrong-type-argument)
(should (equal plist '(x 3 y nil)))
- (should (eq (cl-incf (cl-getf plist 'z 10) 5) 15))
+ (should (eq (incf (cl-getf plist 'z 10) 5) 15))
(should (equal plist '(z 15 x 3 y nil))))
(let ((plist '(x 1 y)))
(should (eq (cl-getf plist 'x) 1))
(should (eq (cl-getf plist 'y :none) :none))
(should (eq (cl-getf plist 'z :none) :none))
- (should (eq (cl-incf (cl-getf plist 'x 10) 2) 3))
+ (should (eq (incf (cl-getf plist 'x 10) 2) 3))
(should (equal plist '(x 3 y)))
- (should (eq (cl-incf (cl-getf plist 'y 10) 4) 14))
+ (should (eq (incf (cl-getf plist 'y 10) 4) 14))
(should (equal plist '(y 14 x 3 y))))
(let ((plist '(x 1 y . 2)))
(should (eq (cl-getf plist 'x) 1))
- (should (eq (cl-incf (cl-getf plist 'x 10) 2) 3))
+ (should (eq (incf (cl-getf plist 'x 10) 2) 3))
(should (equal plist '(x 3 y . 2)))
(should-error (cl-getf plist 'y :none) :type 'wrong-type-argument)
(should-error (cl-getf plist 'z :none) :type 'wrong-type-argument)))
"Test side effects generated by different arithmetic phrase order."
:expected-result :failed
(should
- (equal (let ((x 1)) (cl-loop for i from x to 10 by (cl-incf x) collect i))
+ (equal (let ((x 1)) (cl-loop for i from x to 10 by (incf x) collect i))
'(1 3 5 7 9)))
(should
- (equal (let ((x 1)) (cl-loop for i from x by (cl-incf x) to 10 collect i))
+ (equal (let ((x 1)) (cl-loop for i from x by (incf x) to 10 collect i))
'(1 3 5 7 9)))
(should
- (equal (let ((x 1)) (cl-loop for i to 10 from x by (cl-incf x) collect i))
+ (equal (let ((x 1)) (cl-loop for i to 10 from x by (incf x) collect i))
'(1 3 5 7 9)))
(should
- (equal (let ((x 1)) (cl-loop for i to 10 by (cl-incf x) from x collect i))
+ (equal (let ((x 1)) (cl-loop for i to 10 by (incf x) from x collect i))
'(2 4 6 8 10)))
(should
- (equal (let ((x 1)) (cl-loop for i by (cl-incf x) from x to 10 collect i))
+ (equal (let ((x 1)) (cl-loop for i by (incf x) from x to 10 collect i))
'(2 4 6 8 10)))
(should
- (equal (let ((x 1)) (cl-loop for i by (cl-incf x) to 10 from x collect i))
+ (equal (let ((x 1)) (cl-loop for i by (incf x) to 10 from x collect i))
'(2 4 6 8 10))))
(ert-deftest cl-macs-loop-for-as-arith-invalid ()
(should (equal (cl-loop for x below 3 for y = (+ 10 x) nconc (list x y))
'(0 10 1 11 2 12)))
(should (equal (cl-loop with start = 5
- for x = start then (cl-incf start)
+ for x = start then (incf start)
repeat 5
collect x)
'(5 6 7 8 9))))
'(3 10 2 10 1 10)))
(should (equal (cl-loop with res = 0
for i from 1 to 10
- doing (cl-incf res i)
+ doing (incf res i)
finally (cl-return res))
55))
(should (equal (cl-loop for i from 10
(ert-deftest cl-macs-loop-finally ()
(should (eql (cl-loop for i from 10
finally
- (cl-incf i 10)
+ (incf i 10)
(cl-return i)
while (< i 20))
30)))
(ert-deftest cl-macs-loop-in-ref ()
(should (equal (cl-loop with my-list = (list 1 2 3 4 5)
for x in-ref my-list
- do (cl-incf x)
+ do (incf x)
finally return my-list)
'(2 3 4 5 6))))
(ert-deftest cl-macs-loop-being-elements-of-ref ()
(should (equal (let ((var (list 1 2 3 4 5)))
(cl-loop for x being the elements of-ref var
- do (cl-incf x)
+ do (incf x)
finally return var))
'(2 3 4 5 6))))
(let ((cl (car l)))
(cl-symbol-macrolet
((p (gv-synthetic-place cl (lambda (v) `(setcar l ,v)))))
- (cl-incf p)))
+ (incf p)))
l)
'(1)))
;; Make sure `gv-synthetic-place' isn't macro-expanded before
(should (eql (cl-the integer 42) 42))
(should-error (cl-the integer "abc"))
(let ((side-effect 0))
- (should (= (cl-the integer (cl-incf side-effect)) 1))
+ (should (= (cl-the integer (incf side-effect)) 1))
(should (= side-effect 1))))
(ert-deftest cl-lib-test-typep ()
(should (eql x (nth key-index list)))
(prog1
(list key-index x)
- (cl-incf key-index)))
+ (incf key-index)))
:test
(lambda (a b)
(should (eql a 'foo))
(should (equal b (list test-index
(nth test-index list))))
- (cl-incf test-index)
+ (incf test-index)
(member test-index '(2 3))))))
(should (equal key-index 4))
(should (equal test-index 4))
(i 0))
(let ((result (cl-remove-if-not (lambda (x)
(should (eql x (nth i list)))
- (cl-incf i)
+ (incf i)
(member i '(2 3)))
list)))
(should (equal i 4))
(result nil))
(while !lt!(< index num)!test!
(push index result)!loop!
- (cl-incf index))!end-loop!
+ (incf index))!end-loop!
(nreverse result)))
(defun edebug-test-code-choices (input)
(progn
(push (cons ,g-name 0) ,names-and-numbers)
,g-name)
- (cl-incf (cdr ,g-duplicate))
+ (incf (cdr ,g-duplicate))
(format "%s-%s" ,g-name (cdr ,g-duplicate))))))
(defun edebug-tests-setup-code-file (tmpfile)
(cps-testcase cps-while-incf
(let* ((i 0) (j 10))
(while (< i 10)
- (cl-incf i)
+ (incf i)
(setf j (+ j (* i 10))))
j))
(iter-yield 1)
(error "Test")
(iter-yield 2))
- (cl-incf nr-unwound))))))
+ (incf nr-unwound))))))
(should (equal (iter-next iter) 1))
(should-error (iter-next iter))
(should (equal nr-unwound 1))))
(let ((labelfn-base (lambda (_item _indent) (insert "foo")))
(spy-count 0)
(condition (lambda (_item _indent) nil)))
- (cl-letf (((symbol-function 'hierarchy-labelfn-button) (lambda (_labelfn _actionfn) (lambda (_item _indent) (cl-incf spy-count)))))
+ (cl-letf (((symbol-function 'hierarchy-labelfn-button) (lambda (_labelfn _actionfn) (lambda (_item _indent) (incf spy-count)))))
(funcall (hierarchy-labelfn-button-if labelfn-base condition #'identity) nil nil)
(should (equal spy-count 0)))))
(let ((labelfn-base (lambda (_item _indent) (insert "foo")))
(spy-count 0)
(condition (lambda (_item _indent) t)))
- (cl-letf (((symbol-function 'hierarchy-labelfn-button) (lambda (_labelfn _actionfn) (lambda (_item _indent) (cl-incf spy-count)))))
+ (cl-letf (((symbol-function 'hierarchy-labelfn-button) (lambda (_labelfn _actionfn) (lambda (_item _indent) (incf spy-count)))))
(funcall (hierarchy-labelfn-button-if labelfn-base condition #'identity) nil nil)
(should (equal spy-count 1)))))
(should
(equal
(let-alist (list
- (cons 'test-two (cl-incf let-alist--test-counter))
- (cons 'test-three (cl-incf let-alist--test-counter)))
- (list .test-one .test-two .test-two .test-three .cl-incf))
+ (cons 'test-two (incf let-alist--test-counter))
+ (cons 'test-three (incf let-alist--test-counter)))
+ (list .test-one .test-two .test-two .test-three .incf))
'(nil 1 1 2 nil)))))
(ert-deftest let-alist-remove-dot ()
(while (not (eobp))
(unless (looking-at "noindent\\|^[[:blank:]]*$")
(insert (make-string n ?\s)))
- (cl-incf n)
+ (incf n)
(forward-line))))
(indent-sexp)
(should (equal (buffer-string) correct))))))
(while (not (eobp))
(unless (looking-at "noindent\\|^[[:blank:]]*$")
(insert (make-string n ?\s)))
- (cl-incf n)
+ (incf n)
(forward-line))))
(indent-region (point-min) (point-max))
(should (equal (buffer-string) correct)))))
(let ((sort (lambda (map) (sort (map-pairs map) #'car-less-than-car))))
(with-empty-maps-do map
;; Empty map, without default.
- (should-error (cl-incf (map-elt map 1)) :type 'wrong-type-argument)
+ (should-error (incf (map-elt map 1)) :type 'wrong-type-argument)
(with-suppressed-warnings ((callargs map-elt))
- (should-error (cl-incf (map-elt map 1.0 nil #'=))
+ (should-error (incf (map-elt map 1.0 nil #'=))
:type 'wrong-type-argument))
(should (map-empty-p map))
;; Empty map, with default.
(if (vectorp map)
(progn
- (should-error (cl-incf (map-elt map 1 3)) :type 'args-out-of-range)
+ (should-error (incf (map-elt map 1 3)) :type 'args-out-of-range)
(with-suppressed-warnings ((callargs map-elt))
- (should-error (cl-incf (map-elt map 1 3 #'=))
+ (should-error (incf (map-elt map 1 3 #'=))
:type 'args-out-of-range))
(should (map-empty-p map)))
- (should (= (cl-incf (map-elt map 1 3) 10) 13))
+ (should (= (incf (map-elt map 1 3) 10) 13))
(with-suppressed-warnings ((callargs map-elt))
- (should (= (cl-incf (map-elt map 2.0 5 #'=) 12) 17)))
+ (should (= (incf (map-elt map 2.0 5 #'=) 12) 17)))
(should (equal (funcall sort map) '((1 . 13) (2.0 . 17))))))
(with-maps-do map
;; Nonempty map, without predicate.
- (should (= (cl-incf (map-elt map 1 3) 10) 14))
+ (should (= (incf (map-elt map 1 3) 10) 14))
(should (equal (funcall sort map) '((0 . 3) (1 . 14) (2 . 5))))
;; Nonempty map, with predicate.
(with-suppressed-warnings ((callargs map-elt))
(pcase-exhaustive map
((pred consp)
- (should (= (cl-incf (map-elt map 2.0 6 #'=) 12) 17))
+ (should (= (incf (map-elt map 2.0 6 #'=) 12) 17))
(should (equal (funcall sort map) '((0 . 3) (1 . 14) (2 . 17))))
- (should (= (cl-incf (map-elt map 0 7 #'=) 13) 16))
+ (should (= (incf (map-elt map 0 7 #'=) 13) 16))
(should (equal (funcall sort map) '((0 . 16) (1 . 14) (2 . 17)))))
((pred vectorp)
- (should-error (cl-incf (map-elt map 2.0 6 #'=))
+ (should-error (incf (map-elt map 2.0 6 #'=))
:type 'wrong-type-argument)
(should (equal (funcall sort map) '((0 . 3) (1 . 14) (2 . 5))))
- (should (= (cl-incf (map-elt map 2 6 #'=) 12) 17))
+ (should (= (incf (map-elt map 2 6 #'=) 12) 17))
(should (equal (funcall sort map) '((0 . 3) (1 . 14) (2 . 17))))
- (should (= (cl-incf (map-elt map 0 7 #'=) 13) 16))
+ (should (= (incf (map-elt map 0 7 #'=) 13) 16))
(should (equal (funcall sort map) '((0 . 16) (1 . 14) (2 . 17)))))
((pred hash-table-p)
- (should (= (cl-incf (map-elt map 2.0 6 #'=) 12) 18))
+ (should (= (incf (map-elt map 2.0 6 #'=) 12) 18))
(should (member (funcall sort map)
'(((0 . 3) (1 . 14) (2 . 5) (2.0 . 18))
((0 . 3) (1 . 14) (2.0 . 18) (2 . 5)))))
- (should (= (cl-incf (map-elt map 0 7 #'=) 13) 16))
+ (should (= (incf (map-elt map 0 7 #'=) 13) 16))
(should (member (funcall sort map)
'(((0 . 16) (1 . 14) (2 . 5) (2.0 . 18))
((0 . 16) (1 . 14) (2.0 . 18) (2 . 5)))))))))))
(map nil))
(setf (map-elt map 'foo)
(funcall (lambda ()
- (cl-incf num))))
+ (incf num))))
(should (equal map '((foo . 1))))
;; Check that the function is only called once.
(should (= num 1))))
""
:synchronized t)
(should (= (multisession-value multisession--foo) 0))
- (cl-incf (multisession-value multisession--foo))
+ (incf (multisession-value multisession--foo))
(should (= (multisession-value multisession--foo) 1))
(call-process
(concat invocation-directory invocation-name)
(define-multisession-variable multisession--foo 0
""
:synchronized t)
- (cl-incf (multisession-value multisession--foo))))))
+ (incf (multisession-value multisession--foo))))))
(should (= (multisession-value multisession--foo) 2)))
(sqlite-close multisession--db)
(setq multisession--db nil)))))
""
:synchronized t)
(should (= (multisession-value multisession--bar) 0))
- (cl-incf (multisession-value multisession--bar))
+ (incf (multisession-value multisession--bar))
(should (= (multisession-value multisession--bar) 1))
(setq proc
(start-process
(define-multisession-variable multisession--bar 0
"" :synchronized t)
(dotimes (i 100)
- (cl-incf (multisession-value multisession--bar))))))))
+ (incf (multisession-value multisession--bar))))))))
(while (process-live-p proc)
(ignore-error sqlite-locked-error
(message "multisession--bar %s" (multisession-value multisession--bar))
- ;;(cl-incf (multisession-value multisession--bar))
+ ;;(incf (multisession-value multisession--bar))
)
(sleep-for 0.1))
(message "multisession--bar ends up as %s" (multisession-value multisession--bar))
""
:synchronized t)
(should (= (multisession-value multisession--sfoo) 0))
- (cl-incf (multisession-value multisession--sfoo))
+ (incf (multisession-value multisession--sfoo))
(should (= (multisession-value multisession--sfoo) 1))
;; On Windows and Haiku, we don't have sub-second resolution, so
;; let some time pass to make the "later" logic work.
(define-multisession-variable multisession--sfoo 0
""
:synchronized t)
- (cl-incf (multisession-value multisession--sfoo))))))
+ (incf (multisession-value multisession--sfoo))))))
(should (= (multisession-value multisession--sfoo) 2)))))
(ert-deftest multi-test-files-busy ()
""
:synchronized t)
(should (= (multisession-value multisession--sbar) 0))
- (cl-incf (multisession-value multisession--sbar))
+ (incf (multisession-value multisession--sbar))
(should (= (multisession-value multisession--sbar) 1))
(setq proc
(start-process
(define-multisession-variable multisession--sbar 0
"" :synchronized t)
(dotimes (i 100)
- (cl-incf (multisession-value multisession--sbar))))))))
+ (incf (multisession-value multisession--sbar))))))))
(while (process-live-p proc)
(message "multisession--sbar %s" (multisession-value multisession--sbar))
- ;;(cl-incf (multisession-value multisession--sbar))
+ ;;(incf (multisession-value multisession--sbar))
(sleep-for 0.1))
(message "multisession--sbar ends up as %s" (multisession-value multisession--sbar))
(should (< (multisession-value multisession--sbar) 200)))))
(ocl1 (oclosure-lambda (oclosure-test (fst 1) (snd 2) (name "hi"))
()
(list fst snd i)))
- (ocl2 (oclosure-lambda (oclosure-test (name (cl-incf i)) (fst (cl-incf i)))
+ (ocl2 (oclosure-lambda (oclosure-test (name (incf i)) (fst (incf i)))
()
(list fst snd 152 i))))
(should (equal (list (oclosure-test--fst ocl1)
(should (equal (oclosure-test-mut--mut f) 3))
(should (equal (funcall f 5) 8))
(should (equal (funcall f2 5) 58))
- (cl-incf (oclosure-test-mut--mut f) 7)
+ (incf (oclosure-test-mut--mut f) 7)
(should (equal (oclosure-test-mut--mut f) 10))
(should (equal (funcall f 5) 15))
(should (equal (funcall f2 15) 68))))
(should (eq before3
(if (symbolp before)
before (length before)))))))
- (cl-incf (aref sync-counts (1- n)))
- (cl-incf (aref char-counts (1- n)) (- end beg))
+ (incf (aref sync-counts (1- n)))
+ (incf (aref char-counts (1- n)) (- end beg))
(let ((after (buffer-substring beg end)))
(track-changes-tests--message
"Sync:\n %S\n=> %S\nat %d .. %d"
(((symbol-function 'read-key)
;; Increase counter and answer 'n' when prompted
;; to save a buffer.
- (lambda (&rest _) (cl-incf nb-saved-buffers) ?n))
+ (lambda (&rest _) (incf nb-saved-buffers) ?n))
;; Do not kill Emacs.
((symbol-function 'kill-emacs) #'ignore)
(save-some-buffers-default-predicate callers-dir))
(put-image-calls 0)
(shr-put-image-function
(lambda (&rest args)
- (cl-incf put-image-calls)
+ (incf put-image-calls)
(apply #'shr-put-image args)))
(shr-width 80)
(shr-use-fonts nil)
;; bind `read-string' as well.
(cl-letf (((symbol-function 'read-event)
(lambda (&rest _args)
- (cl-incf ,count)
+ (incf ,count)
(pcase ,count ; Build the clauses from CHAR-NUMS
,@(append
(delq nil
dicta sunt, explicabo. "))
(while (< iteration-count iteration-target)
- (cl-incf iteration-count)
+ (incf iteration-count)
;; Toggle GROWING if we've reached a size boundary. The idea
;; is to initially steadily increase the overlay count, then
(ov (make-overlay begin end nil
(= 0 (random 2)) (= 0 (random 2)))))
(aset overlays overlay-count ov)
- (cl-incf overlay-count)))
+ (incf overlay-count)))
((and (not create-overlay) (> overlay-count 0))
;; Possibly delete a random overlay.
(dolist (n (nreverse nibbles))
(dotimes (_ 4)
(aset bv i (oddp n))
- (cl-incf i)
+ (incf i)
(setf n (ash n -1)))))
bv))
(counter 0)
(my-counter (lambda ()
(if (< counter 500)
- (cl-incf counter)
+ (incf counter)
(setq counter 0)
(garbage-collect))))
(rand 1)
(let ((calls 0))
(add-hook 'after-change-functions
(lambda (_begin _end _length)
- (cl-incf calls)
+ (incf calls)
(signal 'json-tests--error
'("Error in `after-change-functions'")))
:local)
(let ((calls 0))
(add-hook 'after-change-functions
(lambda (_begin _end _length)
- (cl-incf calls)
+ (incf calls)
(throw 'test-tag 'throw-value))
:local)
(should
(mapcar #'intern list))
(defun minibuf-tests--strings-to-symbol-alist (list)
(let ((num 0))
- (mapcar (lambda (str) (cons (intern str) (cl-incf num))) list)))
+ (mapcar (lambda (str) (cons (intern str) (incf num))) list)))
(defun minibuf-tests--strings-to-string-alist (list)
(let ((num 0))
- (mapcar (lambda (str) (cons str (cl-incf num))) list)))
+ (mapcar (lambda (str) (cons str (incf num))) list)))
(defun minibuf-tests--strings-to-obarray (list)
(let ((ob (obarray-make 7)))
(mapc (lambda (str) (intern str ob)) list)
(defun minibuf-tests--strings-to-string-hashtable (list)
(let ((ht (make-hash-table :test #'equal))
(num 0))
- (mapc (lambda (str) (puthash str (cl-incf num) ht)) list)
+ (mapc (lambda (str) (puthash str (incf num) ht)) list)
ht))
(defun minibuf-tests--strings-to-symbol-hashtable (list)
(let ((ht (make-hash-table :test #'equal))
(num 0))
- (mapc (lambda (str) (puthash (intern str) (cl-incf num) ht)) list)
+ (mapc (lambda (str) (puthash (intern str) (incf num) ht)) list)
ht))
;;; Functions that produce a predicate (for *-completion functions)
(should (equal args '(make-process :name "name"
:command ("/some/binary")
:file-handler t)))
- (cl-incf file-handler-calls)
+ (incf file-handler-calls)
'fake-process))
(let ((file-name-handler-alist (list (cons (rx bos "test-handler:")
#'file-handler)))