Skip to content

Commit 8c18bc5

Browse files
committed
Add tests for clojure-max-backtracking
Verify that setting max-backtracking to 0 prevents context lookup for nested forms, while the default depth of 3 allows it.
1 parent 9a1a8e1 commit 8c18bc5

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

test/clojure-mode-indentation-test.el

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,23 @@ x
12731273
;; Just verify it differs from the backtracking result
12741274
(expect result :not :to-equal "\n(letfn [(foo [x]\n (+ x 1))]\n (foo 1))"))))))
12751275

1276+
(describe "clojure-max-backtracking"
1277+
(it "should limit how far up the sexp tree backtracking goes"
1278+
;; With max-backtracking = 0, even one level of backtracking is
1279+
;; disabled, so letfn bindings lose :defn-style indentation.
1280+
(let ((clojure-max-backtracking 0))
1281+
(with-clojure-buffer "\n(letfn [(foo [x]\n(+ x 1))]\n(foo 1))"
1282+
(indent-region (point-min) (point-max))
1283+
(let ((result (buffer-string)))
1284+
(expect result :not :to-equal "\n(letfn [(foo [x]\n (+ x 1))]\n (foo 1))")))))
1285+
1286+
(it "should indent correctly with sufficient backtracking depth"
1287+
;; With the default depth (3), letfn works fine.
1288+
(let ((clojure-max-backtracking 3))
1289+
(with-clojure-buffer "\n(letfn [(foo [x]\n(+ x 1))]\n(foo 1))"
1290+
(indent-region (point-min) (point-max))
1291+
(expect (buffer-string) :to-equal "\n(letfn [(foo [x]\n (+ x 1))]\n (foo 1))")))))
1292+
12761293
(provide 'clojure-mode-indentation-test)
12771294

12781295
;;; clojure-mode-indentation-test.el ends here

0 commit comments

Comments
 (0)