summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2022-07-31 11:48:56 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2022-07-31 12:57:47 +0200
commitf48493577d9dcfddecda5d8b40e156c5c063d9c6 (patch)
tree1ba0b9e8700d252523a1ff24e0ce94470631e432
parentdf8dede8585257a2ee76ed93d6ecb6cf117e124a (diff)
downloademacs-f48493577d9dcfddecda5d8b40e156c5c063d9c6.tar.gz
emacs-f48493577d9dcfddecda5d8b40e156c5c063d9c6.tar.bz2
emacs-f48493577d9dcfddecda5d8b40e156c5c063d9c6.zip
; 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.
-rw-r--r--test/lisp/subr-tests.el13
-rw-r--r--test/src/print-tests.el20
2 files changed, 19 insertions, 14 deletions
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