From b29bf8181fe2c02becd0a3ac5e2f85cb0a3b58bf Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Tue, 23 Mar 2021 23:11:51 -0400 Subject: [PATCH] Add a test for let-binding unwinding Bindings in other buffers are not un-set when we unwind a let-binding which set the default value. There doesn't seem to be an existing test which covers this, so here's one. * test/src/data-tests.el (data-tests--let-buffer-local-no-unwind-other-buffers): Add test for let-binding unwinding behavior --- test/src/data-tests.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/src/data-tests.el b/test/src/data-tests.el index 03d867f18a8..d0cb87293f0 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el @@ -364,6 +364,28 @@ comparing the subr with a much slower lisp implementation." (should (equal (default-value var) (symbol-value var)))) (should (equal (default-value var) def)))))) +(ert-deftest data-tests--let-buffer-local-no-unwind-other-buffers () + "Test that a let-binding for a buffer-local unwinds only current-buffer." + (let ((blvar (make-symbol "blvar"))) + (set-default blvar 0) + (make-variable-buffer-local blvar) + (dolist (var (list blvar 'left-margin)) + (let* ((def (default-value var)) + (newdef (+ def 1)) + (otherbuf (generate-new-buffer "otherbuf"))) + (with-temp-buffer + (cl-progv (list var) (list newdef) + (with-current-buffer otherbuf + (set var 123) + (should (local-variable-p var)) + (should (equal (symbol-value var) 123)) + (should (equal (default-value var) newdef)))) + (with-current-buffer otherbuf + (should (local-variable-p var)) + (should (equal (symbol-value var) 123)) + (should (equal (default-value var) def))) + ))))) + (ert-deftest binding-test-makunbound () "Tests of makunbound, from the manual." (with-current-buffer binding-test-buffer-B -- 2.39.2