|
1248 | 1248 | (indent-region (point-min) (point-max)) |
1249 | 1249 | (expect (buffer-string) :to-equal "\n(ns foo\n (:require\n [bar]))"))))) |
1250 | 1250 |
|
| 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 | + |
1251 | 1276 | (provide 'clojure-mode-indentation-test) |
1252 | 1277 |
|
1253 | 1278 | ;;; clojure-mode-indentation-test.el ends here |
0 commit comments