[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#66042: 30.0.50; ERT test fails while trying to indent pretty-print
From: |
Protesilaos Stavrou |
Subject: |
bug#66042: 30.0.50; ERT test fails while trying to indent pretty-print |
Date: |
Sun, 17 Sep 2023 09:13:06 +0300 |
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
- bug#66042: 30.0.50; ERT test fails while trying to indent pretty-print,
Protesilaos Stavrou <=