Skip to content

Commit e64ec85

Browse files
committed
Add a round-trip test for the debugger coordinate finder
`cider--debug-find-coordinates-for-point' is the inverse of `cider--debug-move-point', but only the latter was covered. Test that feeding the finder's result back into `cider--debug-move-point' lands on the same spot.
1 parent da5808d commit e64ec85

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

test/cider-debug-tests.el

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,29 @@
179179
(cider--debug-move-point '(3 2 1))
180180
(expect (thing-at-point 'symbol) :to-equal "x"))))
181181

182+
(describe "cider--debug-find-coordinates-for-point"
183+
;; `cider--debug-find-coordinates-for-point' is the inverse of
184+
;; `cider--debug-move-point', so feeding its result back into the latter
185+
;; must land on the same spot.
186+
(it "round-trips with cider--debug-move-point"
187+
;; Each form is paired with coordinates known to be valid for it.
188+
(dolist (case '(("(defn a [] (let [x 1] (inc x)) {:a 1, :b 2})" (3 2 1) (3 1 1) (2))
189+
("(defn f [y] (+ (* y 2) (- y 3)))" (3 2 1) (3 1 1))
190+
("(let [x (atom 1)] @x)" (2 1))
191+
("(do @(do (atom {})))" (1 1 1))))
192+
(let ((form (car case)))
193+
(dolist (coord (cdr case))
194+
(with-temp-buffer
195+
(clojure-mode)
196+
(save-excursion (insert form))
197+
(cider--debug-move-point coord)
198+
(let ((target (point)))
199+
(goto-char (point-min))
200+
(let ((found (cider--debug-find-coordinates-for-point target)))
201+
(goto-char (point-min))
202+
(cider--debug-move-point found)
203+
(expect (point) :to-equal target)))))))))
204+
182205
(describe "cider--debug-remember-origin"
183206
(before-each
184207
(setq cider--debug-origin-marker nil

0 commit comments

Comments
 (0)