summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2021-10-19 12:03:15 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2021-10-19 21:59:41 +0200
commit0bb0fbee68498be1a74e03fe97ea3ad9297f8bfe (patch)
tree4c222d96f9873c78e07a89f947d8693e2d4431c8 /test/lisp/emacs-lisp
parent53bea8796d52d90d09c29780070442d59e1883b7 (diff)
downloademacs-0bb0fbee68498be1a74e03fe97ea3ad9297f8bfe.tar.gz
emacs-0bb0fbee68498be1a74e03fe97ea3ad9297f8bfe.tar.bz2
emacs-0bb0fbee68498be1a74e03fe97ea3ad9297f8bfe.zip
Improve TCO test coverage
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Exercise `cond` in tail position in two different ways.
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r--test/lisp/emacs-lisp/cl-macs-tests.el13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el
index f4e2e46a019..033764a7f98 100644
--- a/test/lisp/emacs-lisp/cl-macs-tests.el
+++ b/test/lisp/emacs-lisp/cl-macs-tests.el
@@ -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)))