* Test comment-search-backward
@ 2017-09-10 12:24 N. Raghavendra
2017-09-20 16:10 ` N. Raghavendra
0 siblings, 1 reply; 2+ messages in thread
From: N. Raghavendra @ 2017-09-10 12:24 UTC (permalink / raw
To: emacs-devel
I am using Emacs 26.0.50.1. While testing some functions that I had
defined, I came across a behaviour of `comment-search-backward' that
seems to be at odds with its docstring:
----------------------------------------------------------------------
(comment-search-backward &optional LIMIT NOERROR)
Find a comment start between LIMIT and point.
Moves point to inside the comment and returns the position of the
comment-starter. If no comment is found, moves point to LIMIT
and raises an error or returns nil if NOERROR is non-nil.
Ensure that ‘comment-normalize-vars’ has been called before you use this.
----------------------------------------------------------------------
Here is a file which, I think, defines a test of this behaviour:
[/tmp]$ cat test.el
----------------------------------------------------------------------
(ert-deftest test-comment-search-backward-absent ()
"Test `comment-search-backward' when there is no comment in context.
Check that when there is no comment in the portion of the buffer between
the search limit and point, it moves point to the search limit and raises
an error."
(with-temp-buffer
(emacs-lisp-mode)
(comment-normalize-vars)
(insert "(require 'foo)
\(bar) ; first comment
;; second comment
\(provide 'baz)")
(let ((limit (save-excursion (search-backward "second"))))
(should (equal (should-error (comment-search-backward limit))
'(error "No comment")))
(should (= (point) limit)))))
----------------------------------------------------------------------
Running the test fails:
[/tmp]$ emacs -Q --batch --load=test.el --funcall=ert-run-tests-batch-and-exit
----------------------------------------------------------------------
(ert-test-failed
((should
(=
(point)
limit))
:form
(= 70 41)
:value nil))
FAILED 1/1 test-comment-search-backward-absent
----------------------------------------------------------------------
It looks like `comment-search-backward' does raise an error as promised,
but does not move point to LIMIT from its previous position at the end
of the buffer.
Is there something I am missing?
Thanks,
Raghu.
--
N. Raghavendra <raghu@hri.res.in>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Test comment-search-backward
2017-09-10 12:24 Test comment-search-backward N. Raghavendra
@ 2017-09-20 16:10 ` N. Raghavendra
0 siblings, 0 replies; 2+ messages in thread
From: N. Raghavendra @ 2017-09-20 16:10 UTC (permalink / raw
To: emacs-devel
At 2017-09-10T17:54:57+05:30, N. Raghavendra wrote:
> It looks like `comment-search-backward' does raise an error as promised,
> but does not move point to LIMIT from its previous position at the end
> of the buffer.
I've submitted this as
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28428
The thing is that there's a discrepancy between the docstring of the
function and its effects. I think that since the docstring seems to be
the only specification of the effects of a function, this mismatch
should be removed, either by redefining the function so that its effects
conform to the docstring, or by changing the docstring so that it
correctly describes the effects of the function under its current
definition. Regarding the former, I've submitted a patch and a test
with the above bug, but they may be too naive.
I hope this discrepancy can be removed before the next release.
Cheers,
Raghu.
--
N. Raghavendra <raghu@hri.res.in>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-20 16:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-10 12:24 Test comment-search-backward N. Raghavendra
2017-09-20 16:10 ` N. Raghavendra
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.