* 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
* bug#66042: 30.0.50; ERT test fails while trying to indent pretty-print
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
1 sibling, 0 replies; 5+ messages in thread
From: Mauro Aranda @ 2023-09-17 11:46 UTC (permalink / raw)
To: Protesilaos Stavrou, 66042; +Cc: Lei Zhu
Hi Prot,
Protesilaos Stavrou <info@protesilaos.com> writes:
> 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"))
I tried to reproduce it on current master, but I couldn't. I ran the
test interactively, in case that makes a difference.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#66042: 30.0.50; ERT test fails while trying to indent pretty-print
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
1 sibling, 1 reply; 5+ messages in thread
From: Stefan Kangas @ 2023-09-17 11:47 UTC (permalink / raw)
To: Protesilaos Stavrou, 66042; +Cc: Lei Zhu
Protesilaos Stavrou <info@protesilaos.com> 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?
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#66042: 30.0.50; ERT test fails while trying to indent pretty-print
2023-09-17 11:47 ` Stefan Kangas
@ 2023-09-18 4:54 ` Protesilaos Stavrou
2023-09-18 9:30 ` Mauro Aranda
0 siblings, 1 reply; 5+ messages in thread
From: Protesilaos Stavrou @ 2023-09-18 4:54 UTC (permalink / raw)
To: Stefan Kangas, Mauro Aranda, 66042; +Cc: Lei Zhu
[-- Attachment #1: Type: text/plain, Size: 1483 bytes --]
Hello Stefan, Mauro,
> From: Stefan Kangas <stefankangas@gmail.com>
> 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))))
If I restart Emacs, comment out (indent-sexp), then evaluate the buffer,
and then the ERT test, everything works as expected. There is no
'wholenump' error.
All the best,
Prot
--
Protesilaos Stavrou
https://protesilaos.com
[-- Attachment #2: 2023-09-18_07:50:02_1274x1056.png --]
[-- Type: image/png, Size: 35248 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#66042: 30.0.50; ERT test fails while trying to indent pretty-print
2023-09-18 4:54 ` Protesilaos Stavrou
@ 2023-09-18 9:30 ` Mauro Aranda
0 siblings, 0 replies; 5+ messages in thread
From: Mauro Aranda @ 2023-09-18 9:30 UTC (permalink / raw)
To: 66042; +Cc: Lei Zhu
On 18/9/23 01:54, Protesilaos Stavrou wrote:
> Hello Stefan, Mauro,
>
>> From: Stefan Kangas <stefankangas@gmail.com>
>> 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.
^ 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.