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

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to