diff options
author | Po Lu <luangruo@yahoo.com> | 2021-12-09 10:30:18 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2021-12-09 10:30:18 +0800 |
commit | 47cd820d93d282da484ae91e68021736ed7994bc (patch) | |
tree | a24229d1df8547dfd427ef97cf9968b7f5a1e7a8 /test/lisp/emacs-lisp | |
parent | 41b1d223c6ab7bca1b626a4c07a4f2dda2855feb (diff) | |
parent | 63f07ea22f3954c2154d831017caf494911cb515 (diff) | |
download | emacs-47cd820d93d282da484ae91e68021736ed7994bc.tar.gz emacs-47cd820d93d282da484ae91e68021736ed7994bc.tar.bz2 emacs-47cd820d93d282da484ae91e68021736ed7994bc.zip |
Merge remote-tracking branch 'origin/master' into feature/pgtk
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/cl-macs-tests.el | 12 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/subr-x-tests.el | 20 |
2 files changed, 25 insertions, 7 deletions
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 7c3afefaadd..13da60ec45e 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -668,13 +668,13 @@ collection clause." #'len)) (`(function (lambda (,_ ,_) . ,_)) t)))) -(with-suppressed-warnings ((lexical test) (lexical test1) (lexical test2)) - (defvar test) - (defvar test1) - (defvar test2)) (ert-deftest cl-macs--progv () - (should (= (cl-progv '(test test) '(1 2) test) 2)) - (should (equal (cl-progv '(test1 test2) '(1 2) (list test1 test2)) + (defvar cl-macs--test) + (defvar cl-macs--test1) + (defvar cl-macs--test2) + (should (= (cl-progv '(cl-macs--test cl-macs--test) '(1 2) cl-macs--test) 2)) + (should (equal (cl-progv '(cl-macs--test1 cl-macs--test2) '(1 2) + (list cl-macs--test1 cl-macs--test2)) '(1 2)))) ;;; cl-macs-tests.el ends here diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el index d8369506000..821b6770ba0 100644 --- a/test/lisp/emacs-lisp/subr-x-tests.el +++ b/test/lisp/emacs-lisp/subr-x-tests.el @@ -676,7 +676,7 @@ (buffer-string)) "foo\n"))) -(ert-deftest test-add-display-text-property () +(ert-deftest subr-x-test-add-display-text-property () (with-temp-buffer (insert "Foo bar zot gazonk") (add-display-text-property 4 8 'height 2.0) @@ -694,5 +694,23 @@ [(raise 0.5) (height 2.0)])) (should (equal (get-text-property 9 'display) '(raise 0.5))))) +(ert-deftest subr-x-named-let () + (let ((funs ())) + (named-let loop + ((rest '(1 42 3)) + (sum 0)) + (when rest + ;; Here, we make sure that the variables are distinct in every + ;; iteration, since a naive tail-call optimization would tend to end up + ;; with a single `sum' variable being shared by all the closures. + (push (lambda () sum) funs) + ;; Here we add a dummy `sum' variable which shadows the `sum' iteration + ;; variable since a naive tail-call optimization could also trip here + ;; thinking it can `(setq sum ...)' to set the iteration + ;; variable's value. + (let ((sum sum)) + (loop (cdr rest) (+ sum (car rest)))))) + (should (equal (mapcar #'funcall funs) '(43 1 0))))) + (provide 'subr-x-tests) ;;; subr-x-tests.el ends here |