|
64 | 64 | "Assert that TEXT at position POS gets font-locked with FACE in `julia-mode'."
|
65 | 65 | `(should (eq ,face (julia--get-font-lock ,text ,pos))))
|
66 | 66 |
|
| 67 | +(defun julia--should-move-point-helper (text fun from to &optional end arg) |
| 68 | + "Takes the same arguments as `julia--should-move-point', returns a cons of the expected and the actual point." |
| 69 | + (with-temp-buffer |
| 70 | + (julia-mode) |
| 71 | + (insert text) |
| 72 | + (indent-region (point-min) (point-max)) |
| 73 | + (goto-char (point-min)) |
| 74 | + (if (stringp from) |
| 75 | + (re-search-forward from) |
| 76 | + (goto-char from)) |
| 77 | + (funcall fun arg) |
| 78 | + (let ((actual-to (point)) |
| 79 | + (expected-to |
| 80 | + (if (stringp to) |
| 81 | + (progn (goto-char (point-min)) |
| 82 | + (re-search-forward to) |
| 83 | + (if end (goto-char (match-end 0)) |
| 84 | + (goto-char (match-beginning 0)) |
| 85 | + (point-at-bol))) |
| 86 | + to))) |
| 87 | + (cons expected-to actual-to)))) |
| 88 | + |
67 | 89 | (defmacro julia--should-move-point (text fun from to &optional end arg)
|
68 | 90 | "With TEXT in `julia-mode', after calling FUN, the point should move FROM\
|
69 | 91 | to TO. If FROM is a string, move the point to matching string before calling
|
70 | 92 | function FUN. If TO is a string, match resulting point to point a beginning of
|
71 | 93 | matching line or end of match if END is non-nil. Optional ARG is passed to FUN."
|
72 | 94 | (declare (indent defun))
|
73 |
| - `(with-temp-buffer |
74 |
| - (julia-mode) |
75 |
| - (insert ,text) |
76 |
| - (indent-region (point-min) (point-max)) |
77 |
| - (goto-char (point-min)) |
78 |
| - (if (stringp ,from) |
79 |
| - (re-search-forward ,from) |
80 |
| - (goto-char ,from)) |
81 |
| - (funcall ,fun ,arg) |
82 |
| - (should (eq (point) (if (stringp ,to) |
83 |
| - (progn (goto-char (point-min)) |
84 |
| - (re-search-forward ,to) |
85 |
| - (if ,end (goto-char (match-end 0)) |
86 |
| - (goto-char (match-beginning 0)) |
87 |
| - (point-at-bol))) |
88 |
| - ,to))))) |
| 95 | + `(let ((positions (julia--should-move-point-helper ,text ,fun ,from ,to ,end ,arg))) |
| 96 | + (should (eq (car positions) (cdr positions))))) |
89 | 97 |
|
90 | 98 | ;;; indent tests
|
91 | 99 |
|
|
0 commit comments