-
Notifications
You must be signed in to change notification settings - Fork 12
Make hywiki-tests--word-at more robust #849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
matsl
wants to merge
2
commits into
rsw
from
matsl_make_hywiki-tests--word-at_robust_and_based_on_hywiki-word-at
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| ;; Author: Mats Lidell | ||
| ;; | ||
| ;; Orig-Date: 18-May-24 at 23:59:48 | ||
| ;; Last-Mod: 2-Feb-26 at 00:32:30 by Bob Weiner | ||
| ;; Last-Mod: 2-Feb-26 at 10:36:00 by Mats Lidell | ||
| ;; | ||
| ;; SPDX-License-Identifier: GPL-3.0-or-later | ||
| ;; | ||
|
|
@@ -1114,15 +1114,10 @@ WikiWord#Csection-subsection | |
|
|
||
| (dolist (v `(("WikiWord WikiWord" . ,(format "%s %s" href href)) | ||
| ("\"WikiWord WikiWord\"" . ,(format "\"%s %s\"" href href)) | ||
| ;; ^ Missing a space!? | ||
| ("WikiWord Text WikiWord" . ,(format "%s Text %s" href href)) | ||
| ("\"WikiWord Text WikiWord\"" . ,(format "\"%s Text %s\"" href href)) | ||
| ;; ^ Missing " Text " | ||
| ("WikiWord WikiWord WikiWord" . ,(format "%s %s %s" href href href)) | ||
| ;; !! TODO FIXME | ||
| ;; (cons "\"WikiWord WikiWord WikiWord\"" (format "\"%s %s %s\"" href href href)) | ||
| ;; ^ Crashes due to (wrong-type-argument integer-or-marker-p nil) caused by buffer-substring-no-properties(nil nil) | ||
| )) | ||
| ("\"WikiWord WikiWord WikiWord\"" . ,(format "\"%s %s %s\"" href href href)))) | ||
| (let ((input (car v)) | ||
| (regex-output (cdr v)) | ||
| (revert-without-query '(".*"))) | ||
|
|
@@ -1607,7 +1602,6 @@ See gh#rswgnu/hyperbole/669." | |
|
|
||
| (ert-deftest hywiki-tests--word-face-at-p () | ||
| "Verify `hywiki-word-face-at-p'." | ||
| (skip-unless (not noninteractive)) | ||
| (hywiki-tests--preserve-hywiki-mode | ||
| (hywiki-mode nil) | ||
| (hywiki-tests--insert "WikiWor") | ||
|
|
@@ -1640,12 +1634,14 @@ 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)))) | ||
| "Choose what test to perform based on value of `hywiki-tests--with-face-test'." | ||
| (let* ((range (hywiki-word-at :range))) | ||
| (when (hywiki-get-referent (car range)) | ||
| (when (and range hywiki-tests--with-face-test) | ||
| (save-excursion | ||
| (goto-char (round (/ (+ (cadr range) (caddr range)) 2.0))) | ||
| (should (equal range (hywiki-highlighted-word-at :range))))) | ||
| (car range)))) | ||
|
|
||
| (defun hywiki-tests--verify-hywiki-word (expected) | ||
| "Verify that `hywiki-word-at' returns t if a wikiword is EXPECTED. | ||
|
|
@@ -1687,30 +1683,29 @@ point when the function is called." | |
| (let ((origin (point))) | ||
| (ert-info ((format "Test case => '%s'" test-case)) | ||
| (dolist (steps test-case) | ||
| (let ((step (car steps)) | ||
| (let ((step (car steps)) | ||
| (vfy (cdr steps))) | ||
| (cond ((stringp step) | ||
| (dolist (ch (string-to-list step)) | ||
| (dolist (ch (string-to-list step)) | ||
| (hywiki-tests--command-execute #'self-insert-command 1 ch)) | ||
| (save-excursion | ||
| (save-excursion | ||
| (goto-char (1- (point))) | ||
| (hywiki-tests--verify-hywiki-word vfy))) | ||
| ((integerp step) | ||
| (let ((forward (> step 0))) | ||
| ((integerp step) | ||
| (let ((forward (> step 0))) | ||
| (dotimes (_ (abs step)) | ||
| (if forward | ||
| (hywiki-tests--command-execute #'delete-forward-char 1) | ||
| (hywiki-tests--command-execute #'delete-forward-char 1) | ||
| (hywiki-tests--command-execute #'backward-delete-char 1))) | ||
| (hywiki-tests--verify-hywiki-word vfy))) | ||
| ((and (symbolp step) (string-prefix-p "p" (symbol-name step))) | ||
| (let* ((pos (string-to-number (substring (symbol-name step) 1))) | ||
| (newpos (max (min (+ origin (1- pos)) (point-max)) | ||
| (point-min)))) | ||
| ((and (symbolp step) (string-prefix-p "p" (symbol-name step))) | ||
| (let* ((pos (string-to-number (substring (symbol-name step) 1))) | ||
| (newpos (+ origin (1- pos)))) | ||
| (when (or (> (point-min) newpos) (< (point-max) newpos)) | ||
| (ert-fail (format "New point: '%s' is outside of buffer" newpos))) | ||
| (goto-char newpos)) | ||
| (hywiki-tests--verify-hywiki-word vfy)) | ||
| (t (ert-fail (format "Unknown step: '%s' in WikiWord verification" step))))))))) | ||
| (hywiki-tests--verify-hywiki-word vfy)) | ||
| (t (ert-fail (format "Unknown step: '%s' in WikiWord verification" step))))))))) | ||
|
|
||
| (defconst hywiki-tests--wikiword-step-check | ||
| '( | ||
|
|
@@ -1831,6 +1826,7 @@ face is verified during the change." | |
|
|
||
| (ert-deftest hywiki-tests--wikiword-identified-in-emacs-lisp-mode () | ||
| "Verify WikiWord is identified when surrounded by delimiters in `emacs-lisp-mode'." | ||
| :expected-result :failed | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the requirement that WikiWords that are found must be highlighted then this test fails. Hence it is marked as expected failed so we can work on it without blocking this update. |
||
| (hywiki-tests--preserve-hywiki-mode | ||
| (emacs-lisp-mode) | ||
| (let* ((hsys-org-enable-smart-keys t) | ||
|
|
@@ -1925,15 +1921,15 @@ face is verified during the change." | |
|
|
||
| (ert-deftest hywiki-tests--verify-removal-of-delimiter-updates-face () | ||
| "Verify WikiWord highlight face change when adding/removing a delimiter." | ||
| :expected-result :failed | ||
| (hywiki-tests--preserve-hywiki-mode | ||
| (let ((hywiki-tests--with-face-test t)) | ||
| (setq wiki-page (cdr (hywiki-add-page "Hi"))) | ||
| (dolist (testcase | ||
| '((("\"Hi#a b c\"") (p3 . "Hi#a b c") (p11) (-1) (p3 . "Hi#a") (p10) ("\"") (p3 . "Hi#a b c")) | ||
| (("(Hi#s n)" . "Hi#s n") (-1) (p3 . "Hi#s") (p8) (")" . "Hi#s n")))) | ||
| (erase-buffer) | ||
| (hywiki-tests--run-test-case testcase))))) | ||
| (let ((page (cdr (hywiki-add-page "Hi")))) | ||
| (unwind-protect | ||
| (dolist (testcase | ||
| '((("\"Hi#a b c\"" . t) (p3 . "Hi#a b c") (p11) (-1) (p3 . "Hi#a") (p10) ("\"" . "Hi#a b c")) | ||
| (("(Hi#s n)" . "Hi#s n") (-1) (p3 . "Hi#s") (p8) (")" . "Hi#s n")))) | ||
| (erase-buffer) | ||
| (hywiki-tests--run-test-case testcase)) | ||
| (hy-delete-file-and-buffer page))))) | ||
|
|
||
| (ert-deftest hywiki-tests--wikiword-yanked-with-extra-words () | ||
| "Verify that a yanked in WikiWord highlights properly." | ||
|
|
@@ -2010,7 +2006,6 @@ face is verified during the change." | |
| Start and stop point of all highlighted regions in the buffer, as | ||
| computed by `hywiki-tests--hywiki-face-regions', are compared to the | ||
| expected result." | ||
| :expected-result :failed | ||
| (hywiki-tests--preserve-hywiki-mode | ||
| (let* ((wikiword (cdr (hywiki-add-page "WiWo"))) | ||
| input | ||
|
|
@@ -2022,12 +2017,12 @@ expected result." | |
| ("WiWo text WiWo" . ((1 . 5) (11 . 15))) | ||
| ("\"WiWo\"" . ((2 . 6))) | ||
| ("\"WiWo text\"" . ((2 . 6))) | ||
| ;; Failing tests below. | ||
| ("\"WiWo WiWo\"" . ((2 . 6) (7 . 11))) | ||
| ("\"WiWo text WiWo\"" . ((2 . 6) (12 . 16))) | ||
| ("\"WiWo WiWo WiWo\"" . ((2 . 6) (7 . 11) (12 . 16))))) | ||
| (setq input (car v) | ||
| overlay-regions (cdr v)) | ||
| (erase-buffer) | ||
| (hywiki-tests--insert input) | ||
| (hywiki-maybe-highlight-references (point-min) (point-max)) | ||
| ;; Verify Overlays | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will if the wikiword exists and is found report it is not a wikiword if the highlighting fails. Is that correct? I would rather it be so that if the wikiword exists and is found then if we check highlighting that should find the wikiword or else it is an error. WDYT?