From: Mattias EngdegÄrd Date: Sun, 31 Jul 2022 09:48:56 +0000 (+0200) Subject: ; Use values instead of trying to ignore them X-Git-Tag: emacs-29.0.90~1447^2~606 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f48493577d9dcfddecda5d8b40e156c5c063d9c6;p=emacs.git ; 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. --- diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index bc11e6f3c7d..3d03057f567 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 b503bdeb998..5c349342eb3 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