Subject: Re: bug#66042: 30.0.50; ERT test fails while trying to indent pretty-print

From: Mauro Aranda <[email-masked]>
Date: Mon, 18 Sep 2023 06:30:24 -0300

On 18/9/23 01:54, Protesilaos Stavrou wrote:
 > Hello Stefan, Mauro,
 >
 >> From: Stefan Kangas <[email-masked]>
 >> Date: Sun, 17 Sep 2023 04:47:29 -0700
 >
 >> [... 20 lines elided]
 >
 >> I can't reproduce this on current master.  Evaluating the above two
 >> forms in emacs -Q and then saying
 >
 >> [... 23 lines elided]
 >
 >> Which version of Emacs are you running?
 >>
 >> Can you reproduce it in emacs -Q?
 >
 > Yes, I can reproduce it with 'emacs -Q' on Emacs trunk.  I tried it just
 > now with the following code.  See attached screenshot.
 >
 >      (require 'ert)
 >
 >      (defun ert--pp-with-indentation-and-newline (object)
 >        "Pretty-print OBJECT, indenting it to the current column of point.
 >      Ensures a final newline is inserted."
 >        (let ((begin (point))
 >              (pp-escape-newlines t)
 >              (print-escape-control-characters t))
 >          (pp object (current-buffer))
 >          (unless (bolp) (insert "\n"))
 >          (save-excursion
 >            (goto-char begin)
 >            (indent-sexp)
 >            )))
 >
 >      (ert-deftest my-kill-backward-test-close-parens ()
 >        "aaa)))"
 >        (test-case "aaa)))" 7 "aaa"))
 >
 >      (defun test-case (text pos expected)
 >        (with-temp-buffer
 >          (insert text)
 >          (goto-char pos)
 >          (backward-kill-word 1)
 >          (should (string-equal (buffer-string) expected))))
 >

I can reproduce it now.  Your original recipe didn't include a docstring
for the ERT test.