Skip to content

Commit 7e4aa06

Browse files
p4v4nbbatsov
authored andcommitted
Add and modify tests for checking multiple forms on same line
1 parent e18a1bf commit 7e4aa06

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

Diff for: test/clojure-mode-refactor-threading-test.el

+11-2
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,16 @@
247247

248248
(clojure-unwind '(4)))
249249

250+
(when-refactoring-it "should unwind correctly when multiple ->> are present on same line"
251+
"(->> 1 inc) (->> [1 2 3 4 5]
252+
(filter even?)
253+
(map square))"
254+
255+
"(->> 1 inc) (->> (map square (filter even? [1 2 3 4 5])))"
256+
257+
(clojure-unwind)
258+
(clojure-unwind))
259+
250260
(when-refactoring-it "should unwind with function name"
251261
"(->> [1 2 3 4 5]
252262
sum
@@ -299,8 +309,7 @@
299309

300310
(when-refactoring-it "should unwind some->>"
301311
"(some->> :b
302-
(find {:a 1})
303-
val
312+
(find {:a 1}) val
304313
(+ 5))"
305314

306315
"(some->> (+ 5 (val (find {:a 1} :b))))"

Diff for: test/clojure-mode-sexp-test.el

+14-7
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,37 @@
3131
(wrong))"
3232
;; make this use the native beginning of defun since this is used to
3333
;; determine whether to use the comment aware version or not.
34+
(expect (let ((beginning-of-defun-function nil))
35+
(clojure-top-level-form-p "comment")))))
36+
(it "should return true when multiple forms are present"
37+
(with-clojure-buffer-point
38+
"(+ 1 2) (comment
39+
(wrong)
40+
(rig|ht)
41+
(wrong))"
3442
(expect (let ((beginning-of-defun-function nil))
3543
(clojure-top-level-form-p "comment"))))))
3644

3745
(describe "clojure-beginning-of-defun-function"
3846
(it "should go to top level form"
3947
(with-clojure-buffer-point
40-
"(comment
48+
" (comment
4149
(wrong)
4250
(wrong)
4351
(rig|ht)
4452
(wrong))"
45-
(beginning-of-defun)
53+
(clojure-beginning-of-defun-function)
4654
(expect (looking-at-p "(comment"))))
4755

4856
(it "should eval top level forms inside comment forms when clojure-toplevel-inside-comment-form set to true"
4957
(with-clojure-buffer-point
50-
"(comment
51-
(wrong)
58+
"(+ inc 1) (comment
5259
(wrong)
53-
(rig|ht)
60+
(wrong) (rig|ht)
5461
(wrong))"
5562
(let ((clojure-toplevel-inside-comment-form t))
56-
(beginning-of-defun))
57-
(expect (looking-at-p "[[:space:]]*(right)"))))
63+
(clojure-beginning-of-defun-function))
64+
(expect (looking-at-p "(right)"))))
5865

5966
(it "should go to beginning of previous top level form"
6067
(with-clojure-buffer-point

0 commit comments

Comments
 (0)