diff options
author | Yuuki Harano <masm+github@masm11.me> | 2021-01-10 18:49:51 +0900 |
---|---|---|
committer | Yuuki Harano <masm+github@masm11.me> | 2021-01-10 18:49:51 +0900 |
commit | aac33a8074c41354ffdb1236a342da16dca4a1bc (patch) | |
tree | 3a99478549f66d3f93a282e29d2c302995a86a49 /test/lisp/emacs-lisp | |
parent | 78fd106653a9e4fa7c9c3c9788540e2e15552254 (diff) | |
parent | 690cf6b8d8b8827f046bc1e24b2e556afeff976c (diff) | |
download | emacs-aac33a8074c41354ffdb1236a342da16dca4a1bc.tar.gz emacs-aac33a8074c41354ffdb1236a342da16dca4a1bc.tar.bz2 emacs-aac33a8074c41354ffdb1236a342da16dca4a1bc.zip |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs into feature/pgtk
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound.el | 7 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 3 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/cl-macs-tests.el | 23 |
3 files changed, 33 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound.el b/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound.el new file mode 100644 index 00000000000..e65a541e6e3 --- /dev/null +++ b/test/lisp/emacs-lisp/bytecomp-resources/warn-obsolete-variable-bound.el @@ -0,0 +1,7 @@ +;;; -*- lexical-binding: t -*- + +(make-obsolete-variable 'bytecomp--tests-obsolete-var-2 nil "99.99") + +(defun foo () + (let ((bytecomp--tests-obsolete-var-2 2)) + bytecomp--tests-obsolete-var-2)) diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 5e5f99dbdab..a07af188fac 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -625,6 +625,9 @@ Subtests signal errors if something goes wrong." (bytecomp--define-warning-file-test "warn-obsolete-variable.el" "bytecomp--tests-obs.*obsolete.*99.99") +(bytecomp--define-warning-file-test "warn-obsolete-variable-bound.el" + "bytecomp--tests-obs.*obsolete.*99.99" t) + (bytecomp--define-warning-file-test "warn-redefine-defun-as-macro.el" "as both function and macro") diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 446983c2e3e..bcd63f73a3c 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -610,4 +610,27 @@ collection clause." ;; Just make sure the function can be instrumented. (edebug-defun))) +;;; cl-labels + +(ert-deftest cl-macs--labels () + ;; Simple recursive function. + (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))) + + ;; Check that non-recursive functions are handled more efficiently. + (should (pcase (macroexpand '(cl-labels ((f (x) (+ x 1))) (f 5))) + (`(let* ,_ (funcall ,_ 5)) t))) + + ;; Case of "tail-recursive lambdas". + (should (pcase (macroexpand + '(cl-labels ((len (xs n) (if xs (len (cdr xs) (1+ n)) n))) + #'len)) + (`(function (lambda (,_ ,_) . ,_)) t)))) + ;;; cl-macs-tests.el ends here |