Skip to content

Commit

Permalink
add potential tests for treatment of comments at end of file.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick Scherer committed Jan 25, 2015
1 parent 38036ba commit 5392ba0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion test/rewrite_clj/zip/insert_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[rewrite-clj.zip
[base :as base]
[move :as m]
[insert :refer :all]]))
[insert :refer :all]]
[fast-zip.core :as z]))

(tabular
(fact "about whitespace-aware insertion."
Expand All @@ -29,3 +30,10 @@
"[%s]" 0 append-child "[1 2 3 4 x]"
"[ %s]" 0 insert-child "[x 1 2 3 4]"
"[%s ]" 0 append-child "[1 2 3 4 x]")

(future-fact
"about inserting after comment."
(let [loc (-> (base/of-string "[1 2 3] ; this is a comment")
(z/rightmost)
(insert-right 'x))]
(base/root-string loc) => "[1 2 3] ; this is a comment\nx"))
10 changes: 9 additions & 1 deletion test/rewrite_clj/zip/remove_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[rewrite-clj.zip
[base :as base]
[move :as m]
[remove :as r]]))
[remove :as r]]
[fast-zip.core :as z]))

(tabular
(fact "about whitespace-aware removal."
Expand Down Expand Up @@ -34,3 +35,10 @@
(-> root m/next m/down r/remove base/root-string)
=> (str " :k [[d e f]]\n"
" :keyword 0")))

(future-fact
"about removing after comment."
(let [loc (-> (base/of-string "; comment\nx")
(z/rightmost)
(r/remove))]
(base/root-string loc) => "; comment"))

0 comments on commit 5392ba0

Please sign in to comment.