Skip to content

Commit ce8f03e

Browse files
p4v4nkommen
authored andcommitted
Fix clojure-sort-ns with comments in the end (#646)
Closes #645
1 parent 95206a5 commit ce8f03e

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

clojure-mode-util-test.el

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,49 @@
136136
(expect (buffer-string) :to-equal
137137
"(ns my-app.core
138138
(:require [my-app.views [user-page :as user-page]]
139-
[rum.core :as rum] ;comment\n))")))
139+
[rum.core :as rum] ;comment
140+
))")))
141+
142+
(it "should sort requires in a basic ns with comments in the end"
143+
(with-clojure-buffer "(ns my-app.core
144+
(:require [rum.core :as rum] ;comment
145+
[my-app.views [user-page :as user-page]]
146+
;;[comment2]
147+
))"
148+
(clojure-sort-ns)
149+
(expect (buffer-string) :to-equal
150+
"(ns my-app.core
151+
(:require [my-app.views [user-page :as user-page]]
152+
[rum.core :as rum] ;comment
153+
154+
;;[comment2]
155+
))")))
156+
(it "should sort requires in ns with copyright disclamer and comments"
157+
(with-clojure-buffer ";; Copyright (c) John Doe. All rights reserved.
158+
;; The use and distribution terms for this software are covered by the
159+
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
160+
(ns clojure.core
161+
(:require
162+
;; The first comment
163+
[foo] ;; foo comment
164+
;; Middle comment
165+
[bar] ;; bar comment
166+
;; A last comment
167+
))"
168+
(clojure-sort-ns)
169+
(expect (buffer-string) :to-equal
170+
";; Copyright (c) John Doe. All rights reserved.
171+
;; The use and distribution terms for this software are covered by the
172+
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
173+
(ns clojure.core
174+
(:require
175+
;; Middle comment
176+
[bar] ;; bar comment
177+
;; The first comment
178+
[foo] ;; foo comment
179+
180+
;; A last comment
181+
))")))
140182

141183
(it "should also sort imports in a ns"
142184
(with-clojure-buffer "\n(ns my-app.core

0 commit comments

Comments
 (0)