diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2022-07-31 11:48:56 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2022-07-31 12:57:47 +0200 |
commit | f48493577d9dcfddecda5d8b40e156c5c063d9c6 (patch) | |
tree | 1ba0b9e8700d252523a1ff24e0ce94470631e432 /test/src/print-tests.el | |
parent | df8dede8585257a2ee76ed93d6ecb6cf117e124a (diff) | |
download | emacs-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.
Diffstat (limited to 'test/src/print-tests.el')
-rw-r--r-- | test/src/print-tests.el | 20 |
1 files changed, 11 insertions, 9 deletions
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 |