summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp
diff options
context:
space:
mode:
authorAndrea Corallo <akrl@sdf.org>2021-03-19 15:28:00 +0100
committerAndrea Corallo <akrl@sdf.org>2021-03-19 15:28:00 +0100
commit6ca6c71cd0bf8fc970d9b1477ea61a670469f672 (patch)
tree98876b3f80794a8aad43293fbe005102e26e94f9 /test/lisp/emacs-lisp
parentb3ad62f8a35617366886be2a86e8641282824adf (diff)
parent3af2cee64b86e4ce59adb8e8720d92db35039cbc (diff)
downloademacs-6ca6c71cd0bf8fc970d9b1477ea61a670469f672.tar.gz
emacs-6ca6c71cd0bf8fc970d9b1477ea61a670469f672.tar.bz2
emacs-6ca6c71cd0bf8fc970d9b1477ea61a670469f672.zip
Merge remote-tracking branch 'savannah/master' into native-comp
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r--test/lisp/emacs-lisp/cl-macs-tests.el25
1 files changed, 20 insertions, 5 deletions
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el
index 2e5f3020b41..df1d26a074e 100644
--- a/test/lisp/emacs-lisp/cl-macs-tests.el
+++ b/test/lisp/emacs-lisp/cl-macs-tests.el
@@ -617,11 +617,26 @@ collection clause."
(cl-labels ((len (xs) (if xs (1+ (len (cdr xs))) 0)))
(should (equal (len (make-list 42 t)) 42)))
- ;; Simple tail-recursive function.
- (cl-labels ((len (xs n) (if xs (len (cdr xs) (1+ n)) n)))
- (should (equal (len (make-list 42 t) 0) 42))
- ;; Should not bump into stack depth limits.
- (should (equal (len (make-list 42000 t) 0) 42000)))
+ (let ((list-42 (make-list 42 t))
+ (list-42k (make-list 42000 t)))
+
+ (cl-labels
+ ;; Simple tail-recursive function.
+ ((len (xs n) (if xs (len (cdr xs) (1+ n)) n))
+ ;; Slightly obfuscated version to exercise tail calls from
+ ;; `let', `progn', `and' and `or'.
+ (len2 (xs n) (or (and (not xs) n)
+ (let (n1)
+ (and xs
+ (progn (setq n1 (1+ n))
+ (len2 (cdr xs) n1)))))))
+ (should (equal (len nil 0) 0))
+ (should (equal (len2 nil 0) 0))
+ (should (equal (len list-42 0) 42))
+ (should (equal (len2 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))))
;; Check that non-recursive functions are handled more efficiently.
(should (pcase (macroexpand '(cl-labels ((f (x) (+ x 1))) (f 5)))