Skip to content

Commit 9a1a8e1

Browse files
committed
Add tests for clojure-use-backtracking-indent
Verify that when backtracking is disabled: - Simple specs (integer, :defn) still work correctly - Complex list-based specs (letfn) lose nested context
1 parent 2cc7ed7 commit 9a1a8e1

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/clojure-mode-indentation-test.el

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,31 @@ x
12481248
(indent-region (point-min) (point-max))
12491249
(expect (buffer-string) :to-equal "\n(ns foo\n (:require\n [bar]))")))))
12501250

1251+
(describe "clojure-use-backtracking-indent"
1252+
(it "should still indent simple specs correctly when disabled"
1253+
(let ((clojure-use-backtracking-indent nil))
1254+
;; Integer spec (when has spec 1)
1255+
(with-clojure-buffer "\n(when true\nbody)"
1256+
(indent-region (point-min) (point-max))
1257+
(expect (buffer-string) :to-equal "\n(when true\n body)"))
1258+
;; :defn spec
1259+
(with-clojure-buffer "\n(defn foo\n[x]\nx)"
1260+
(indent-region (point-min) (point-max))
1261+
(expect (buffer-string) :to-equal "\n(defn foo\n [x]\n x)"))))
1262+
1263+
(it "should lose context for complex specs when disabled"
1264+
(let ((clojure-use-backtracking-indent nil))
1265+
;; Without backtracking, the body of a letfn binding won't get
1266+
;; :defn-style indentation because the backtracking that walks
1267+
;; up to letfn's spec (1 ((:defn)) nil) is disabled.
1268+
(with-clojure-buffer "\n(letfn [(foo [x]\n(+ x 1))]\n(foo 1))"
1269+
(indent-region (point-min) (point-max))
1270+
;; The body of foo should NOT get :defn-style (2-space) indent
1271+
;; relative to foo — instead it gets default alignment.
1272+
(let ((result (buffer-string)))
1273+
;; Just verify it differs from the backtracking result
1274+
(expect result :not :to-equal "\n(letfn [(foo [x]\n (+ x 1))]\n (foo 1))"))))))
1275+
12511276
(provide 'clojure-mode-indentation-test)
12521277

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

0 commit comments

Comments
 (0)