Skip to content

Commit 5392ba0

Browse files
author
Yannick Scherer
committed
add potential tests for treatment of comments at end of file.
1 parent 38036ba commit 5392ba0

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

test/rewrite_clj/zip/insert_test.clj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
[rewrite-clj.zip
44
[base :as base]
55
[move :as m]
6-
[insert :refer :all]]))
6+
[insert :refer :all]]
7+
[fast-zip.core :as z]))
78

89
(tabular
910
(fact "about whitespace-aware insertion."
@@ -29,3 +30,10 @@
2930
"[%s]" 0 append-child "[1 2 3 4 x]"
3031
"[ %s]" 0 insert-child "[x 1 2 3 4]"
3132
"[%s ]" 0 append-child "[1 2 3 4 x]")
33+
34+
(future-fact
35+
"about inserting after comment."
36+
(let [loc (-> (base/of-string "[1 2 3] ; this is a comment")
37+
(z/rightmost)
38+
(insert-right 'x))]
39+
(base/root-string loc) => "[1 2 3] ; this is a comment\nx"))

test/rewrite_clj/zip/remove_test.clj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
[rewrite-clj.zip
44
[base :as base]
55
[move :as m]
6-
[remove :as r]]))
6+
[remove :as r]]
7+
[fast-zip.core :as z]))
78

89
(tabular
910
(fact "about whitespace-aware removal."
@@ -34,3 +35,10 @@
3435
(-> root m/next m/down r/remove base/root-string)
3536
=> (str " :k [[d e f]]\n"
3637
" :keyword 0")))
38+
39+
(future-fact
40+
"about removing after comment."
41+
(let [loc (-> (base/of-string "; comment\nx")
42+
(z/rightmost)
43+
(r/remove))]
44+
(base/root-string loc) => "; comment"))

0 commit comments

Comments
 (0)