Skip to content

Commit 2cc7ed7

Browse files
committed
Add tests for clojure-indent-keyword-style
Test all three values (always-align, always-indent, align-arguments) with :require forms inside ns, covering both case A (arg on same line as keyword) and case B (no args on same line).
1 parent 2007e53 commit 2cc7ed7

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

test/clojure-mode-indentation-test.el

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,40 @@ x
12141214
'(put-clojure-indent 'foo "bar"))
12151215
:to-throw)))
12161216

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+
12171251
(provide 'clojure-mode-indentation-test)
12181252

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

0 commit comments

Comments
 (0)