mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Improve TCO test coverage
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Exercise `cond` in tail position in two different ways.
This commit is contained in:
parent
53bea8796d
commit
0bb0fbee68
1 changed files with 11 additions and 2 deletions
|
|
@ -637,17 +637,26 @@ collection clause."
|
|||
(/ 1 (logand n 1))
|
||||
(arith-error (len3 (cdr xs) (1+ n)))
|
||||
(:success (len3 (cdr xs) (+ n k))))
|
||||
n)))
|
||||
n))
|
||||
|
||||
;; Tail calls in `cond'.
|
||||
(len4 (xs n)
|
||||
(cond (xs (cond (nil 'nevertrue)
|
||||
((len4 (cdr xs) (1+ n)))))
|
||||
(t n))))
|
||||
(should (equal (len nil 0) 0))
|
||||
(should (equal (len2 nil 0) 0))
|
||||
(should (equal (len3 nil 0) 0))
|
||||
(should (equal (len4 nil 0) 0))
|
||||
(should (equal (len list-42 0) 42))
|
||||
(should (equal (len2 list-42 0) 42))
|
||||
(should (equal (len3 list-42 0) 42))
|
||||
(should (equal (len4 list-42 0) 42))
|
||||
;; Should not bump into stack depth limits.
|
||||
(should (equal (len list-42k 0) 42000))
|
||||
(should (equal (len2 list-42k 0) 42000))
|
||||
(should (equal (len3 list-42k 0) 42000))))
|
||||
(should (equal (len3 list-42k 0) 42000))
|
||||
(should (equal (len4 list-42k 0) 42000))))
|
||||
|
||||
;; Check that non-recursive functions are handled more efficiently.
|
||||
(should (pcase (macroexpand '(cl-labels ((f (x) (+ x 1))) (f 5)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue