aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMattias EngdegÄrd2022-07-31 11:48:56 +0200
committerMattias EngdegÄrd2022-07-31 12:57:47 +0200
commitf48493577d9dcfddecda5d8b40e156c5c063d9c6 (patch)
tree1ba0b9e8700d252523a1ff24e0ce94470631e432 /test
parentdf8dede8585257a2ee76ed93d6ecb6cf117e124a (diff)
downloademacs-f48493577d9dcfddecda5d8b40e156c5c063d9c6.tar.gz
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')
-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."))
1042 1042
1043(ert-deftest test-print-unreadable-function () 1043(ert-deftest test-print-unreadable-function ()
1044 ;; Check that problem with unwinding properly is fixed (bug#56773). 1044 ;; Check that problem with unwinding properly is fixed (bug#56773).
1045 (with-temp-buffer 1045 (let* ((before nil)
1046 (let ((buf (current-buffer))) 1046 (after nil)
1047 (let ((_ (readablep (make-marker)))) nil) ; this `let' silences a 1047 (r (with-temp-buffer
1048 ; warning 1048 (setq before (current-buffer))
1049 (should (eq buf (current-buffer)))))) 1049 (prog1 (readablep (make-marker))
1050 (setq after (current-buffer))))))
1051 (should (equal after before))
1052 (should (equal r nil))))
1050 1053
1051(ert-deftest test-string-lines () 1054(ert-deftest test-string-lines ()
1052 (should (equal (string-lines "") '(""))) 1055 (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."
530 0))))))))))) 530 0)))))))))))
531 531
532(ert-deftest test-print-unreadable-function-buffer () 532(ert-deftest test-print-unreadable-function-buffer ()
533 (with-temp-buffer 533 (let* ((buffer nil)
534 (let ((current (current-buffer)) 534 (callback-buffer nil)
535 callback-buffer) 535 (str (with-temp-buffer
536 (let ((print-unreadable-function 536 (setq buffer (current-buffer))
537 (lambda (_object _escape) 537 (let ((print-unreadable-function
538 (setq callback-buffer (current-buffer))))) 538 (lambda (_object _escape)
539 (let ((_ (prin1-to-string (make-marker)))) nil)) ; this `let' silences a 539 (setq callback-buffer (current-buffer))
540 ; warning 540 "tata")))
541 (should (eq current callback-buffer))))) 541 (prin1-to-string (make-marker))))))
542 (should (eq callback-buffer buffer))
543 (should (equal str "tata"))))
542 544
543(provide 'print-tests) 545(provide 'print-tests)
544;;; print-tests.el ends here 546;;; print-tests.el ends here