|
1214 | 1214 | '(put-clojure-indent 'foo "bar")) |
1215 | 1215 | :to-throw))) |
1216 | 1216 |
|
| 1217 | +(describe "clojure-indent-keyword-style" |
| 1218 | + (it "should align keyword forms with always-align (default)" |
| 1219 | + (let ((clojure-indent-keyword-style 'always-align)) |
| 1220 | + ;; Case A: arg on same line → align with it |
| 1221 | + (with-clojure-buffer "\n(ns foo\n(:require\n[bar]))" |
| 1222 | + (indent-region (point-min) (point-max)) |
| 1223 | + (expect (buffer-string) :to-equal "\n(ns foo\n (:require\n [bar]))")) |
| 1224 | + ;; Case B: no arg on same line → align with keyword |
| 1225 | + (with-clojure-buffer "\n(ns foo\n(:require [bar]\n[baz]))" |
| 1226 | + (indent-region (point-min) (point-max)) |
| 1227 | + (expect (buffer-string) :to-equal "\n(ns foo\n (:require [bar]\n [baz]))")))) |
| 1228 | + |
| 1229 | + (it "should indent keyword forms with always-indent" |
| 1230 | + (let ((clojure-indent-keyword-style 'always-indent)) |
| 1231 | + ;; Case A: arg on same line → still indented like body |
| 1232 | + (with-clojure-buffer "\n(ns foo\n(:require [bar]\n[baz]))" |
| 1233 | + (indent-region (point-min) (point-max)) |
| 1234 | + (expect (buffer-string) :to-equal "\n(ns foo\n (:require [bar]\n [baz]))")) |
| 1235 | + ;; Case B: no arg on same line → indented like body |
| 1236 | + (with-clojure-buffer "\n(ns foo\n(:require\n[bar]))" |
| 1237 | + (indent-region (point-min) (point-max)) |
| 1238 | + (expect (buffer-string) :to-equal "\n(ns foo\n (:require\n [bar]))")))) |
| 1239 | + |
| 1240 | + (it "should indent keyword forms with align-arguments" |
| 1241 | + (let ((clojure-indent-keyword-style 'align-arguments)) |
| 1242 | + ;; Case A: arg on same line → align with first arg |
| 1243 | + (with-clojure-buffer "\n(ns foo\n(:require [bar]\n[baz]))" |
| 1244 | + (indent-region (point-min) (point-max)) |
| 1245 | + (expect (buffer-string) :to-equal "\n(ns foo\n (:require [bar]\n [baz]))")) |
| 1246 | + ;; Case B: no arg on same line → indented like body |
| 1247 | + (with-clojure-buffer "\n(ns foo\n(:require\n[bar]))" |
| 1248 | + (indent-region (point-min) (point-max)) |
| 1249 | + (expect (buffer-string) :to-equal "\n(ns foo\n (:require\n [bar]))"))))) |
| 1250 | + |
1217 | 1251 | (provide 'clojure-mode-indentation-test) |
1218 | 1252 |
|
1219 | 1253 | ;;; clojure-mode-indentation-test.el ends here |
0 commit comments