Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
2026-02-09 Mats Lidell <matsl@gnu.org>

* test/hywiki-tests.el (hywiki-tests--run-test-case): Use pos as given
by the step definition. If an illegal position results the test
specification is wrong and need to be changed. Give an error
message that explains the problem.
* test/hywiki-tests.el (hywiki-tests--word-at): Extend verification to
verify that the range of the WikiWord and the range of the
highlighted text is equal iff a highlighted WikiWord exists.
(hywiki-tests--run-test-case): Use pos as given by the step
definition. If an illegal position results the test specification is
wrong and need to be changed. Give an error message that explains the
problem.

2026-02-09 Bob Weiner <rsw@gnu.org>

Expand Down
23 changes: 17 additions & 6 deletions test/hywiki-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -1493,12 +1493,23 @@ comparison with expected overlays stable."
"Non-nil to perform face validation of WikiWord.")

(defun hywiki-tests--word-at ()
"Test if there is a HyWikiWord reference at point with a referent.
Choose what test to perform based on value of `hywiki-tests--with-face-test'."
(when (hywiki-referent-exists-p)
(if hywiki-tests--with-face-test
(hywiki-highlighted-word-at)
(hywiki-word-at))))
"Return potential HyWikiWord and optional #section:Lnum:Cnum at point or nil.
When `hywiki-tests--with-face-test' is non-nil the HyWikiWord must be
highlighted to be returned. When it is highlighted, the range of the
highlighting and the range of the HyWikiWord is, as a side effect,
checked for consistency."
(let* ((range (hywiki-referent-exists-p :range))
(wikiword (car range)))
(when wikiword
(if (not hywiki-tests--with-face-test)
wikiword
(save-excursion
(goto-char (round (/ (+ (cadr range) (caddr range)) 2.0)))
(let* ((highlighted-range (hywiki-highlighted-word-at :range))
(highlighted-wikiword (car highlighted-range)))
(when highlighted-wikiword
(should (equal range highlighted-range)))
highlighted-wikiword))))))

(defun hywiki-tests--verify-hywiki-word (step expected)
"Verify that `hywiki-word-at' returns t if a wikiword is EXPECTED.
Expand Down