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

From: Stefan Kangas <[email-masked]>
Date: Sun, 17 Sep 2023 04:47:29 -0700

Protesilaos Stavrou <[email-masked]> writes:

> I have encountered a possible bug with an ERT test where it is trying to
> perform indentation and fails with:
>
>     lisp-indent-initial-state: Wrong type argument: wholenump, -2
>
> This is the test I am running:
>
>     (defun test-case (text pos expected)
>       (with-temp-buffer
>         (insert text)
>         (goto-char pos)
>         (backward-kill-word 1)
>         (should (string-equal (buffer-string) expected))))
>
>     (ert-deftest my-test ()
>       (test-case "aaa)))" 7 "aaa"))

I can't reproduce this on current master.  Evaluating the above two
forms in emacs -Q and then saying

    M-x ert RET t RET

yields a new buffer "*ert*" containing

    Selector: t
    Passed:  0
    Failed:  1 (1 unexpected)
    Skipped: 0
    Total:   1/1

    Started at:   2023-09-17 13:44:28+0200
    Finished.
    Finished at:  2023-09-17 13:44:28+0200

    F

    F my-test
        (ert-test-failed
         ((should (string-equal (buffer-string) expected)) :form
          (string-equal "" "aaa") :value nil :explanation
          (arrays-of-different-length 0 3 "" "aaa" first-mismatch-at 0)))

Which version of Emacs are you running?

Can you reproduce it in emacs -Q?