Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 919ec90

Browse files
committed
t-utils-sweep-test-ts-grammar: add error line with '^' pointer
1 parent 4dca06d commit 919ec90

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

tests/t-utils.el

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
;; */
132132
;;
133133
;; To create a test that contains a number of tests cases (*.lang files), you write a test
134-
;; driver, say test-LANGAGE-ts-mode-indent-xr that invokes `t-utils-test-xr'.
134+
;; driver, say test-LANGUAGE-ts-mode-indent-xr that invokes `t-utils-test-xr'.
135135
;;
136136
;; 5. Sweep tests
137137
;;
@@ -2463,12 +2463,28 @@ each element is a cons pair (NAME . NODE)."
24632463
(end-col (save-excursion
24642464
(goto-char end-point)
24652465
(1+ (current-column)))))
2466-
(push (format "%s node at line %d:%d to %d:%d (point %d to %d)"
2466+
(push (format "%s node at line %d:%d to %d:%d (point %d to %d)
2467+
%5d | %s
2468+
| %s^
2469+
"
24672470
(treesit-node-type error-node)
24682471
start-line start-col
24692472
end-line end-col
24702473
start-point
2471-
end-point)
2474+
end-point
2475+
start-line
2476+
;; error line
2477+
(buffer-substring (save-excursion
2478+
(goto-char start-point)
2479+
(line-beginning-position))
2480+
(save-excursion
2481+
(goto-char start-point)
2482+
(line-end-position)))
2483+
;; space padding for the pointer (^)
2484+
(save-excursion
2485+
(goto-char start-point)
2486+
(let ((n-spaces (- start-point (line-beginning-position))))
2487+
(make-string n-spaces ? ))))
24722488
result-list)))
24732489
(reverse result-list)))
24742490

@@ -2636,7 +2652,7 @@ Similar `treesit--explorer-draw-node' but designed for test baselines."
26362652
;; Consider foo.m containing:
26372653
;; foo.out1
26382654
;; If we use (field-name (treesit-node-field-name node)) we get different answers
2639-
;; dependening on the version of libtree-sitter.so or .dll. Adding in the let below
2655+
;; depending on the version of libtree-sitter.so or .dll. Adding in the let below
26402656
;; (message "\
26412657
;; node: %S
26422658
;; field-name: %S
@@ -2910,7 +2926,7 @@ To debug a specific -parser test file
29102926
(provide 't-utils)
29112927
;;; t-utils.el ends here
29122928

2913-
;; LocalWords: lang defun alist eos treesit lf setq truename dolist nondirectory bos buf funcall
2929+
;; LocalWords: lang defun alist eos treesit lf setq truename dolist nondirectory bos buf funcall nt
29142930
;; LocalWords: consp listp cdr CRLF impl tmp xr boundp SPC kbd prin progn defmacro sexp stdlib locs
29152931
;; LocalWords: showall repeat:nil kkk fff Dkkkk kkkkkk mapcar eobp trim'd bol NPS prev puthash
2916-
;; LocalWords: maphash lessp gethash nbutlast mapconcat ppss imenu pcase eow NAME's
2932+
;; LocalWords: maphash lessp gethash nbutlast mapconcat ppss imenu pcase eow NAME's darwin libtree

0 commit comments

Comments
 (0)