]> git.eshelyaron.com Git - emacs.git/commitdiff
; Use values instead of trying to ignore them
authorMattias Engdegård <mattiase@acm.org>
Sun, 31 Jul 2022 09:48:56 +0000 (11:48 +0200)
committerMattias Engdegård <mattiase@acm.org>
Sun, 31 Jul 2022 10:57:47 +0000 (12:57 +0200)
* 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
test/src/print-tests.el

index bc11e6f3c7de8154d5f349d84d5fabc0511b58e5..3d03057f56780446bad510f9a63bc93a45e8b46f 100644 (file)
@@ -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 "") '("")))
index b503bdeb998b4dc32fcdcd5dc6d937bc30743bcd..5c349342eb31e503acd21933a8360be5b75e1f47 100644 (file)
@@ -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