emacs-diffs
[Top][All Lists]
Advanced

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

master f48493577d 1/2: ; Use values instead of trying to ignore them


From: Mattias Engdegård
Subject: master f48493577d 1/2: ; Use values instead of trying to ignore them
Date: Sun, 31 Jul 2022 07:03:20 -0400 (EDT)

branch: master
commit f48493577d9dcfddecda5d8b40e156c5c063d9c6
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    ; Use values instead of trying to ignore them
    
    * test/lisp/subr-tests.el (test-print-unreadable-function):
    * test/src/print-tests.el (test-print-unreadable-function-buffer):
    Instead of binding the value of nominally side-effect-free
    expressions to an ignored variable (_), make use of them.
    This is more robust and provides useful extra checks in the test.
---
 test/lisp/subr-tests.el | 13 ++++++++-----
 test/src/print-tests.el | 20 +++++++++++---------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index bc11e6f3c7..3d03057f56 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -1042,11 +1042,14 @@ final or penultimate step during initialization."))
 
 (ert-deftest test-print-unreadable-function ()
   ;; Check that problem with unwinding properly is fixed (bug#56773).
-  (with-temp-buffer
-    (let ((buf (current-buffer)))
-      (let ((_ (readablep (make-marker)))) nil) ; this `let' silences a
-                                                ; warning
-      (should (eq buf (current-buffer))))))
+  (let* ((before nil)
+         (after nil)
+         (r (with-temp-buffer
+              (setq before (current-buffer))
+              (prog1 (readablep (make-marker))
+                (setq after (current-buffer))))))
+    (should (equal after before))
+    (should (equal r nil))))
 
 (ert-deftest test-string-lines ()
   (should (equal (string-lines "") '("")))
diff --git a/test/src/print-tests.el b/test/src/print-tests.el
index b503bdeb99..5c349342eb 100644
--- a/test/src/print-tests.el
+++ b/test/src/print-tests.el
@@ -530,15 +530,17 @@ otherwise, use a different charset."
                                  0)))))))))))
 
 (ert-deftest test-print-unreadable-function-buffer ()
-  (with-temp-buffer
-    (let ((current (current-buffer))
-          callback-buffer)
-      (let ((print-unreadable-function
-             (lambda (_object _escape)
-               (setq callback-buffer (current-buffer)))))
-        (let ((_ (prin1-to-string (make-marker)))) nil))  ; this `let' 
silences a
-                                                          ; warning
-      (should (eq current callback-buffer)))))
+  (let* ((buffer nil)
+         (callback-buffer nil)
+         (str (with-temp-buffer
+                (setq buffer (current-buffer))
+                (let ((print-unreadable-function
+                       (lambda (_object _escape)
+                         (setq callback-buffer (current-buffer))
+                         "tata")))
+                  (prin1-to-string (make-marker))))))
+      (should (eq callback-buffer buffer))
+      (should (equal str "tata"))))
 
 (provide 'print-tests)
 ;;; print-tests.el ends here



reply via email to

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