emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master bb0a5eb41f1: Add tests for `let' (bug#66117)


From: Eli Zaretskii
Subject: master bb0a5eb41f1: Add tests for `let' (bug#66117)
Date: Sat, 30 Dec 2023 02:39:04 -0500 (EST)

branch: master
commit bb0a5eb41f183b37015d09190b56ac8ce6e3c5c8
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Eli Zaretskii <eliz@gnu.org>

    Add tests for `let' (bug#66117)
    
    * test/src/eval-tests.el (eval-tests/default-value): New test.
---
 test/src/eval-tests.el | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index 4589763b2f5..c1219591e40 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -282,4 +282,25 @@ expressions works for identifiers starting with period."
   (should-error (defvaralias 'eval-tests--my-c 'eval-tests--my-d)
                 :type 'cyclic-variable-indirection))
 
+(defvar eval-tests/global-var 'value)
+(defvar-local eval-tests/buffer-local-var 'value)
+(ert-deftest eval-tests/default-value ()
+  ;; `let' overrides the default value for global variables.
+  (should (default-boundp 'eval-tests/global-var))
+  (should (eq 'value (default-value 'eval-tests/global-var)))
+  (should (eq 'value eval-tests/global-var))
+  (let ((eval-tests/global-var 'bar))
+    (should (eq 'bar (default-value 'eval-tests/global-var)))
+    (should (eq 'bar eval-tests/global-var)))
+  ;; `let' overrides the default value everywhere, but leaves
+  ;; buffer-local values unchanged in current buffer and in the
+  ;; buffers where there is no explicitly set buffer-local value.
+  (should (default-boundp 'eval-tests/buffer-local-var))
+  (should (eq 'value (default-value 'eval-tests/buffer-local-var)))
+  (should (eq 'value eval-tests/buffer-local-var))
+  (with-temp-buffer
+    (let ((eval-tests/buffer-local-var 'bar))
+      (should (eq 'bar (default-value 'eval-tests/buffer-local-var)))
+      (should (eq 'bar eval-tests/buffer-local-var)))))
+
 ;;; eval-tests.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]