Hi,
upon further thought, I don't know if here or emacs-devel is the place
to discuss whether there should be a flag à la :failure-expected to
signal that you know that there are "repeated" searches that should not
be treated as non-duplicates.
In a longer test it might end-up being 1) tedious to roght, and 2)
difficult to follow.
An alternative would be a `should-ignore-dup' macro...
WDTY?
/PA
On 19/09/2026 17:27, Ihor Radchenko wrote:
"Pedro A. Aranda" <[email protected]> writes:
This is expected false-positive.
You technically do have duplicate statements in the test:
(goto-char (point-min))
...
(should (search-forward-regexp "^100 & test"))
...
(should (search-forward-regexp "^100 & test"))))
That's what the duplicate detector complains about.
Hmmm... Then I think I have a misconception here. I read it as
"there is no assumption about the starting point of either call
to search-forward-regexp". What am I not understanding here?
Where is the point (if there is such) before and after calling
`search-forward-regexp'?
Your test is perfectly fine.
The duplicate detector is looking to different common failure case.
For example, consider
(should (eq 'element (org-element-class '(foo nil) nil)))
(should (eq 'element (org-element-class '(foo nil) '(center-block nil))))
(should (eq 'element (org-element-class '(foo nil) '(org-data nil))))
(should (eq 'element (org-element-class '(foo nil)
'(center-block nil))))
The
(should (eq 'element (org-element-class '(foo nil) '(center-block nil))))
is a duplicate in the above, the duplicate detector would identify
it.
Your case with search-forward is a different case because it implicitly
depends on point position, and the should statements in your test are
not testing the same thing - point moves between the calls.
As suggested in the failure message, you can use
`org-test-ignore-duplicate' to suppress this false-positive failure.
Does this imply that `org-test-ignore-duplicate' assumes the point
is after the match?
All it does is marks the test case to be ignored when checking for duplicates.
--
Pedro A. Aranda
ox-latex & ox-beamer maintainer
Sagen's Paradeiser! (ORF: Als Radiohören gefährlich war) => write BE!
IA: onomatopeya del rebuzno
2nd year of the New Koprocracy