Skip to content

Commit 920045f

Browse files
committed
Add indentation tests for defmethod, multi-arity defn, nested letfn, and try/catch/finally
These forms all have indent specs but lacked dedicated tests verifying their indentation output: - defmethod with dispatch values (:defn style) - Multi-arity defn with and without docstrings/metadata - Nested letfn verifying the complex '(1 ((:defn)) nil) spec propagates correctly through multiple nesting levels - try/catch/finally verifying specs 0/2/0
1 parent 6456b5d commit 920045f

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

test/clojure-mode-indentation-test.el

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,60 @@ DESCRIPTION is a string with the description of the spec."
512512
(with-out-binding [out messages]
513513
(.flush out))))")
514514

515+
(when-indenting-it "should handle defmethod"
516+
"
517+
(defmethod foo :bar
518+
[x]
519+
(println x))"
520+
521+
"
522+
(defmethod foo :default
523+
[x y]
524+
(+ x y))")
525+
526+
(when-indenting-it "should handle multi-arity defn"
527+
"
528+
(defn foo
529+
([x]
530+
(foo x 1))
531+
([x y]
532+
(+ x y)))"
533+
534+
"
535+
(defn foo
536+
\"docstring\"
537+
([x]
538+
(foo x 1))
539+
([x y]
540+
(+ x y)))"
541+
542+
"
543+
(defn ^:private foo
544+
([x]
545+
(foo x 1))
546+
([x y]
547+
(+ x y)))")
548+
549+
(when-indenting-it "should handle nested letfn"
550+
"
551+
(letfn [(foo [x]
552+
(let [y (inc x)]
553+
(* y y)))
554+
(bar [a]
555+
(letfn [(baz [b]
556+
(+ a b))]
557+
(baz 1)))]
558+
(foo (bar 10)))")
559+
560+
(when-indenting-it "should handle try/catch/finally"
561+
"
562+
(try
563+
(dangerous)
564+
(catch Exception e
565+
(println e))
566+
(finally
567+
(cleanup)))")
568+
515569
(when-indenting-it "should handle reader conditionals"
516570
"#?@ (:clj []
517571
:cljs [])")

0 commit comments

Comments
 (0)