all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#66042: 30.0.50; ERT test fails while trying to indent pretty-print
@ 2023-09-17  6:13 Protesilaos Stavrou
  2023-09-17 11:46 ` Mauro Aranda
  2023-09-17 11:47 ` Stefan Kangas
  0 siblings, 2 replies; 5+ messages in thread
From: Protesilaos Stavrou @ 2023-09-17  6:13 UTC (permalink / raw)
  To: 66042; +Cc: Lei Zhu

Dear maintainers,

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"))

Upon investigating further, I found that 'ert--pp-with-indentation-and-newline'
performs an 'indent-sexp'.  When I comment that out and redefine the
function, the test no longer reports an indentation error with
wholenump.  The test fails gracefully, as expected.  Thus, the whole
file I am using is this:

    (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)
          )))

    (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"))

To be clear, my test should fail, but that is expected.  I encountered
the ERT wholenump issue which prevented me from going further.

Is the indentation expected behaviour?  Can we disable any/all
indentation of sexps within a test?

Thank you for your time,
Protesilaos (or simply "Prot")

-- 
Protesilaos Stavrou
https://protesilaos.com





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-18  9:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-17  6:13 bug#66042: 30.0.50; ERT test fails while trying to indent pretty-print Protesilaos Stavrou
2023-09-17 11:46 ` Mauro Aranda
2023-09-17 11:47 ` Stefan Kangas
2023-09-18  4:54   ` Protesilaos Stavrou
2023-09-18  9:30     ` Mauro Aranda

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.